readgif(3f) - [M_pixel__readgif] read a GIF file (LICENSE:PD)
Synopsis
Description
Options
Example
Authors
License
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
read the num_imageth gif image from filename into arrays image and color_map
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 [char46]true.for verbose output
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 endifwrite(*,*)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
Jos Bergervoet, Van Snyder, Maurizio Cremonesi, Clive Page, and others
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.
Nemo Release 3.1 | readgif (3m_pixel__readgif) | April 21, 2023 |