M_pixel__readgif Module

NAME

readgif(3f) - [M_pixel__readgif] read a GIF file
(LICENSE:PD)

SYNOPSIS

subroutine readgif(filename, num_image, image, iostat, color_map, verbose)

character(len=*), intent(in) :: filename
integer, intent(in)          :: num_image
integer, intent(out), allocatable :: image(:,:)
integer, intent(out)         :: iostat
real   , allocatable, intent(out) :: color_map(:,:)
logical, intent(in), optional :: verbose

DESCRIPTION

read the num_image'th gif image from filename into arrays image and color_map

OPTIONS

filename    input file
num_image   number of image required
image       Image data returned
iostat      I/O error number, =0 if ok
color_map   RGB for each level, range 0.0 to 1.0
verbose     .true.for verbose output

EXAMPLE

Sample program:

   program demo_readgif
   use M_pixel__readgif, only : readgif
   use M_pixel__writegif, only : writegif
   implicit none
   character(len=*),parameter :: filename='boxes.gif'
   integer                    :: num_image=1
   integer,allocatable        :: image(:,:)
   integer                    :: iostat=0
   real,allocatable           :: color_map(:,:)
   integer,allocatable        :: color_map2(:,:)
   logical                    :: verbose=.true.
   integer                    :: i,ii,jj
   call readgif(filename,num_image,image,iostat,color_map,verbose)
   if(iostat.ne.0)then
      write(*,*)'*demo_readgif* could not read GIF file ',trim(filename)
      stop
   endif

   write(*,*)'SIZE OF IMAGE =',size(image)
   do i=1,rank(image)
      write(*,*)'RANK OF IMAGE=',i,size(image,dim=i)
   enddo

   write(*,*)'SIZE OF COLORMAP=',size(color_map)
   do i=1,rank(color_map)
      write(*,*)'RANK OF COLORMAP=',i,size(color_map,dim=i)
   enddo

   ! convert between colormap types
   ! writegif uses an integer colormap, values 0 to 255
   ! readgif  uses real values 0.0 to 1.0
   ii=size(color_map,dim=1)
   jj=size(color_map,dim=2)
   if(allocated(color_map2))deallocate(color_map2)
   allocate(color_map2(ii,0:jj-1))
   color_map2=255*color_map

   ! change color and write standard gif file
   where (image.eq.1) image=4
   call writegif('boxes_new.gif',image,color_map2)

   end program demo_readgif

AUTHORS

Jos Bergervoet, Van Snyder, Maurizio Cremonesi, Clive Page, and others

LICENSE

This module contains a subroutine readgif(3f) which can read GIF files
of types Gif87a and Gif89 (and maybe others). The code comes from
various authors, see comments below. This version was put together
by Clive Page who has put it into the public domain.

Contents


Variables

Type Visibility Attributes Name Initial
type(gif89_type), public :: gif89
type(gif_screen_type), public :: gif_screen
integer, public, parameter :: max_colormap_size = 256

Derived Types

type, public ::  gif89_type

Components

Type Visibility Attributes Name Initial
integer, public :: delaytime
integer, public :: disposal
integer, public :: inputflag
integer, public :: transparent

type, public ::  gif_screen_type

Components

Type Visibility Attributes Name Initial
integer, public :: aspect_ratio
integer, public :: background
integer, public :: bit_pixel
integer, public :: color_map_size
integer, public :: color_resolution
integer, public :: height
logical, public :: use_local_colormap
integer, public :: width

Subroutines

public subroutine readgif(filename, num_image, image, iostat, color_map, verbose)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(in) :: num_image
integer, intent(out), allocatable :: image(:,:)
integer, intent(out) :: iostat
real, intent(out), allocatable :: color_map(:,:)
logical, intent(in), optional :: verbose