Hi chaps,
I've just had a go and simply picked the centre pixel from a rectangular area of the original image. If the thumbnail size is say 60 wide, then just step through the original image in 60 steps. Similarly in the vertical, create a new array with the reduced set and display it.
No interpolation and no averaging. It just seems to work.
Thanks for the hints and here is the code.
Ian
PS If the image is a line drawing, it is easy to miss narrow vertical and horizontal lines by this method, and perhaps the averaging method should be applied.
WINAPP
INCLUDE <windows.ins>
CHARACTER*256 file
integer*1, allocatable a(:,:,:)
integer*1, allocatable b(:,:,:)
INTEGER hres,vres,nb_colours,ier,i,k,control,hres_new,vres_new
!c--- Note - you may need to alter this path
file='PICT2115.bmp'
CALL get_dib_size@(file,hres,vres,nb_colours,ier)
print *,hres,vres,ier,nb_colours
allocate (a(3,hres,vres))
CALL get_dib_block@(file,a,hres,hres,0,0,hres,vres,0,0,ier)
IF(ier.NE.0) STOP 'TROUBLE'
!allocate the thumbnail with the same aspect ratio as the original and the biggest size
! as 256 bits wide
imax_thumb_size = 60
if(hres .gt. vres)then
hres_new = imax_thumb_size
vres_new = vres*imax_thumb_size/hres
else
vres_new = imax_thumb_size
hres_new = hres*imax_thumb_size/vres
endif
print *,hres_new,vres_new
allocate (b(3,0:hres_new-1,0:vres_new-1))
ixratio = float(hres)/hres_new
iyratio = float(vres)/vres_new
ipickx_offset = ixratio/2
ipicky_offset = iyratio/2
print *,ixratio,iyratio,ipickx_offset,ipicky_offset
do ix = 0,hres_new-1
ix_orig = ipickx_offset + ix*ixratio
do iy = 0,vres_new-1
iy_orig = ipicky_offset + iy*iyratio
b(1:3,ix,iy) = a(1:3,ix_orig,iy_orig)
enddo
enddo
!c--- Display the image
i=winio@('%gr%lw',800,800,control)
CALL display_dib_block@(0,0,b,hres_new,vres_new,0,0,hres_new,vres_new,0,0,ier)
deallocate (a,b)
END