Silverfrost Forums

Welcome to our forums

GIF file from %og graphics ?

26 Oct 2014 12:21 #14940

Looks like you need

    CALL Release_Screen_Dib@(iBMP_Handle)
26 Oct 2014 10:38 #14942

I modified the code to produce 100 progressively larger .bmp, .png and .gif images. It all appears to have worked, until the exit read, which did not work. It generates about 1,000 mb of graphics files and finishes with little memory usage. I did not use the .bmp import. At the end, memory usage was 12 mb.

John

      winapp 
       program test 
       implicit none 
       include <windows.ins> 

       character*1, allocatable, dimension(:,:,:) :: DIB_image

       integer*4     n, i,j,k, nx, ny, screen_handle
       character*256 ifile, gfile,pfile

       do n = 0,99
         write (ifile,fmt='(a,i2.2,a)') 'test_',n,'.bmp'
         write (gfile,fmt='(a,i2.2,a)') 'test_',n,'.png'
         write (pfile,fmt='(a,i2.2,a)') 'test_',n,'.gif'

!    create 24-bits test image 
         nx = 800+n*25  ! increased from 10 to test larger DIB images
         ny = 600+n*20  ! was 15
         allocate ( DIB_image(3,nx,ny), stat=j )
          if ( j /= 0 ) then
            write (*,*) 'stop at ALOOCATE for n=',n
            stop
          end if
         do i = 1,ny
           do j = 1,nx 
             k = (j*3-2)
             DIB_image(1,j,i) = char(mod(k,255)) 
             DIB_image(2,j,i) = char(mod(i,255)) 
             DIB_image(3,j,i) = char(mod(i+k,255)) 
           end do 
         end do 

!    off-screen graphics & export to BMP 
         screen_handle = 4
         j  = create_graphics_region@ (screen_handle, nx, ny) 
          if ( j /= 1 ) then
            write (*,*) 'stop at create_graphics_region@ for n=',n
            stop
          end if
         j  = select_graphics_object@ (screen_handle) 
          if ( j /= 1 ) then
            write (*,*) 'stop at select_graphics_object@ for n=',n
            stop
          end if
!
         call display_dib_block@ (0,0,              &  ! the position (X, Y) on the current graphics device
                                  DIB_image,nx,ny,  &  ! the DIB array
                                  0,0,nx,ny,        &  ! position on the current graphics device
                                  0,0,j)               ! FUNCTION,MODE,ERCODE )
          if ( j /= 0 ) then
            write (*,*) 'stop at display_dib_block@ for n=',n
            stop
          end if
!
         if (j == 0) then
           j = export_image@ (ifile) 
            if ( j == 0 ) write (*,*) 'unable to create ',trim(ifile)
           j = export_image@ (gfile) 
            if ( j == 0 ) write (*,*) 'unable to create ',trim(gfile)
           j = export_image@ (pfile) 
            if ( j == 0 ) write (*,*) 'unable to create ',trim(pfile)
         end if
!
         j = delete_graphics_region@ (screen_handle) 
         deallocate ( DIB_image )
       end do
       write (*,*) 'test completed; check memory usage'
       read  (*,*) n

       end
27 Oct 2014 7:43 #14947

John, I think it is not what was needed. Can you make the same creation of graphics files not in main program but in the subroutine/function calling it 100 times with and without deallocate inside the subroutine/function?

27 Oct 2014 9:11 #14950

Thank Paul,

using 'CALL Release_Screen_Dib@(iBMP_Handle)' the memory is not increasing anymore - as well without deallocate.

Erwin

7 Nov 2014 10:33 #14998

John,

I have implemented your code. It works fine and faster. Thank you as well for your private hint. I decided to allow users to apply GIF or PNG files. You are right: Using Clearwin+ the PNG files have perfect colors - GIF files are not as good, as well if you have just a few different colors. The reason is the mode in Clearwin+: Export_Image@ uses with high probability a fixed color palette. When I make a screen copy with Ctrl+Print and create a GIF file in Photoshop, my colors in the file are perfect. Photoshop can use a flexible color palette.

Paul,

change request: Please allow a flexible color palette for GIF files in Export_Image@, because GIF files are for line graphics much smaller then PNG files.

Erwin

7 Nov 2014 11:45 #14999

Erwin,

In 2012, I had a lot of help from Robert to improve the .gif colour palette, but the alternative of .png was a much better solution. Although the fixed .gif palette available in clearwin+ is a deficiency, I have found .png provides a better solution and is supported by all graphics import software that I use. With the latest example I posted on this topic, the larger .png images are actually smaller files than the .gif

John

7 Nov 2014 3:10 #15002

John,

I noticed the size of files in your example, and I agree that png can be applied for many more graphic types then gif. In my case, 5 of my 6 graphic programs are just line graphics with at least 90% sometimes 99% background color. In this case png files are 3 to 4 times larger than gif files. With a variable color palette the images are identical.

Erwin

13 Mar 2015 8:28 #15890

For Create_Graphics_Region@ I read in the description: The colour mode for the surface will be determined by the default colour mode or by the colour mode of the current %gr drawing surface.

Default is 16 colours. How can I set the colour mode to RGB when I have no %gr region but %og?

Erwin

13 Mar 2015 1:52 #15892

I can not give a definitive answer because I am out of my office for a while. I think that the colour mode refers to the old VGA colours against RGB mode. I suggest that you look at the %og documentation and the OPENGL documentation.

Please login to reply.