My understanding is that gif is nolonger restricted and can be used in ClearWin+. You will need a salflibc.dll that is not too old.
.pcx support
In that case the ability to create animated gif files would be a very useful addition to ftn95.
There are free applications around that allow you to create gif files.These can then be imported into a ClearWin+ script.
Catch up ! .gif is no longer patented .gif files can be created in clearwin+ (single files that is) see history in this post Andrew, are you the author of this capability ? Paul, I agree that these dumps are basically a stand-alone function, but I don't have the time to write a .png dumper. I was asking if we can get control of or access to the restricted colour palette in the .gif file. It would be good to be able to scan the screen/dump window and count the number of different colours that are in use and check if this table of most active colours could be used in the .gif palette. I was wondering if .png is only a small change from .gif, then it may be a possible enhancement. Again I do not have experience in writing a .gif like screen dump, with it's more complex compression. My graphics software has a virtual screen of (x,y,z,colour) and I dump to the real screen by drawing lines of the same colour.
John
I was responsible for importing the jpeg functionality in ClearWin+ from public domain software. I did not write the detail of the code.
I can look at the gif code in the ClearWin+ library for you and also the png format.
I have tried using EXPORT_GIF@ and with GDI graphics all is well (when used in conjunction with GET_SCREEN_BLOCK@)
However I have a problem with OpenGL graphics.
I followed a procedure that has worked fine with the export of PCX files from OpenGL graphics.
That is:-
1). call glReadPixels to get the image data into a character array (which may need some padding inserted) 2). call put_dib_block@ to write the image data to a temporary bitmap file 3). Use import_bmp@ on the temporary bitmap file
4). then either call export_pcx@ for PCX files which works fine
or call export_gif@ for GIF files which gives me this message:-
“Error 376, Attempt to delete unallocated storage”
The only difference in the code is “PCX” is replaced with “GIF”
Any ideas anyone?
John,
I had that same error, but the later update from Andrew on 6-Jul-2009 fixed the problem. See posts above and on previous page. Versions since then have also worked.
John
Hi John,
I'm using the salflibc.dll dated 03/07/09 , but my ftn95 is version 5.10.0
I am confused by the problem, because when I grab the image from a GDI (%gr) window it works fine. For OpenGL (%og) I effectively copy and translate the screen image into a GDI format for the Silverfrost routines, which works fine when creating jpeg, bitmap and pcx files and copying to clipboard, but not for gif.
cheers, John
Back to .gif colours, I did a scan of my screen dump and I found:
- I have 120 colours in my rainbow pallette,
- plus 3 shades of grey for the boundary plus red and green for some text.
- There are also 100 other colours which appear to be toned shades at the edge of black text This gives a total of 225 colours in use in my rainbow screen. I checked another type of screen shading, based on 16 shades of blue, + 3 greys + red and green, plus about 280 other shades of background text colours. I've found these other colours, by whiteing out the primary 120 (or 16) colours of my palette and seeing what is left on the screen, which is ghosted text. Presumably this makes the text look better (?) My aim is to get all the colours of my pallette into the .gif file. I note that .gif files use an 8-bit character for the colour. Does that mean that there is table of 2^8 (256) possible colours ? Is it possible to redefine the colours in this table for each .gif file, to be the first 256 colours in use on the screen ? Better still, the 256 most used colours, then the balance is matched to the most alike in the 256 available in the table. As I only have 225 colours active, either would work well.
Is this a possibility for .gif files ?
John
I have looked at the ClearWin+ code and there appears to be no provision for png files. Looks like it would be a major task to add this fucntionality.
I am assuming that the GIF file output from CLearWin+ is standard conforming and that the standard is available somewhere on the internet.
Paul,
I looked in Wikipedia at .gif. It claims that the .gif file uses 256 colours in an indexed table. It appears to me that the colour table used in .gif files created in clearwin+ is fixed and not based on the colour pallete in use on the screen. What I would like is that the .gif writer could choose a better colour palette. My reference, 'Wikipedia' does not indicate that the colour table is fixed, although if I write a .gif file in Microsoft Paint, it doesn't appear to select a most suitable palette either. I have written a routine, which finds all possible colours on the screen and the pixel count for each colour. I start the colour index by giving my pre-defined 120 colours then add new ones as I go. I would need to modify this to limit the number of active colours to 256 then provide an index number (0-255) for each active colour, by choosing the closest colour for those above colour 255. My recomendation is to use the 256 colours with the highest pixel count. Is it possible to include in the .gif writer the ability to select the colour palette based on the colours that most often appear on the screen. This could be as an option, say Set_GIF_Colour_Palette (ncol, RGB_LIST). The code I have written is almost there
subroutine report_region_colours
!
! Routine to report the number of active colours for the current window
!
include <clearwin.ins>
include 'crtcom.ins'
!
integer*4 width, height, hor, ver
integer*4 ncol, i, values(1024), count(1024), value, white
integer*1 vv(4)
equivalence (value, vv)
!
call GET_GRAPHICAL_RESOLUTION@ ( WIDTH, HEIGHT )
!
! tone_map(1:200), max_tone,
ncol = max_tone
if (ncol>0) values(1:max_tone) = tone_map(1:max_tone)
count = 0
white = values(1)
!
do hor = 0,width-1
do ver = 0,height-1
!
call GET_RGB_VALUE@ ( HOR, VER, VALUE )
!
do i = 1,ncol
if (value /= values(i)) cycle
count(i) = count(i) + 1
exit
end do
if (i > ncol .and. ncol < 1024) then
ncol = i
values(i) = value
count(i) = 1
end if
if (i <= max_tone) call draw_point@ ( HOR, VER, white )
!
end do
end do
!
write (98,9001) width, height, max_tone+1, ncol
9001 format (/' Statistics of Screen Dump Colours'/ &
' Horizontal resolution ',i6/ &
' Vertical resolution ',i6/ &
' Number of defined colours',i4/ &
' Number of active colours',i5/ &
' Id Colour Count')
do i = 1,ncol
value = values(i)
write (98,9002) i, vv(1:3), count(i)
end do
9002 format (i4,3o5,2i7)
!
end
I could also change this to limit the number of colours on the screen to 255, if .gif writer then used a dynamic palette.
Paul,
I have now written a pre-dump scanner of the active graphics region that limits the number of active colours to less than 256. There are lots of pixels around text which use a colour only for a few pixels on the screen. Presumably this is some kind of colour merging to better shape the text. The program above helps identify the location of these pixels. I'm not asking for any change to this as it is easy to group and re-colour these to a near active colour, reducing the number of colours to < 256. The image and text does not appear to change noticeably. All that is now needed is for the clearwin+ .gif dump utility 'write_graphics_to_gif@' to use a colour palette based on the active colours, rather than a pre-defined palette. Is that change a possibility ?
John