forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DIB_BLOCK limits
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Feb 20, 2012 12:39 pm    Post subject: Reply with quote

This post has highlighted to me that DIB is another option for updating the active graphics window.
I have developed my own hidden line shading, based on the pixel depth. To update the active window, in the past, I have:
1) Started with Draw_point@ to update the pixel colour and get_RGB_Value@ to get the pixel colour of the active window.
2) I moved from draw_point@ to draw_line_between@ to improve the update rates.
3) Recently I have started to introduced user_surface into “winio@ ('%`^gr grey, user_resize, rgb_colours, full_mouse_input, user_surface]&'” to allow direct addressing of the graphics surface. I have not fully tested this option.
4) DIB offers a way of retrieving or setting the RGB colours for the active screen, using a single call, presumably much quicker than draw_point@ but possibly slower than direct addressing. It clearly can access any virtual graphics surface. Any size can be managed when character*1 PARRAY(3,mx,my) is declared allocatable.
User_surface has the advantage of direct addressing of the graphics information. The pointer changes value with a window resize and (I hope) with calls to select_graphics_object@ (is this the case ?). It has the disadvantage of a more complex addressing method, as in:
Code:
      integer*4 rgb_i(3)
      iw = clearwin_info@ ('GRAPHICS_WIDTH')
      id = clearwin_info@ ('GRAPHICS_DEPTH')
      jw = ((3*iw+3)/4)*4                           ! each row starts on 4_byte address
!
      do ver = 0,id-1
         do hor = 0,iw-1
!         get colour from direct addressing
            jj = ptr_RGB_Address + hor*3 + ver*jw
            rgb_i(1) = core1(jj)   ; if (rgb_i(1) < 0) rgb_i(1) = rgb_i(1)+256     ! blue
            rgb_i(2) = core1(jj+1) ; if (rgb_i(2) < 0) rgb_i(2) = rgb_i(2)+256     ! green
            rgb_i(3) = core1(jj+2) ; if (rgb_i(3) < 0) rgb_i(3) = rgb_i(3)+256     ! red
            rgb_all  = rgb_i(3) + 256*(rgb_i(2) + 256*rgb_i(1))
            …

(is there an intrinsic “byte (core1(jj))” which is an unsigned integer 0:255 ?)
It may be that an alternative to user_surface is to use the DIB interface.
DIB has the advantage of easier addressing of the graphics object, with character*1 PARRAY(3,mx,my), but an apparent problem with mx > 2048.
Can anyone comment on the relative disadvantage of DIB vs , user_surface ?

John
Back to top
View user's profile Send private message
silicondale



Joined: 15 Mar 2007
Posts: 243
Location: Matlock, Derbyshire, UK

PostPosted: Mon Feb 20, 2012 1:31 pm    Post subject: Reply with quote

Excellent thought, John - as long as you bear in mind the x-direction 2048 pixels limitation. If there's a way to get around that, it would be superb!

Meanwhile, I'm now working along the SVG route. Being vector-oriented rather than pixels, and also providing the scaleability, it has some distinbct advantages for mapping - I am working on geological and mine design applications. SVG does also offer a number of area-fill options, so usable for shaded maps too, not just line drawings. Small disadvantage for web appliocations is that it doesn't have the same web browser support as JPEG and GIF - it can be displayed in web pages, but through <object> rather than <img>.

I've also found that generating SVG is much faster than JPG or GIF, at least for the trivial test examples I've been running. File sizes tend to be quite small as well. Although the XML format is verbose, there's no need to store anything for blank areas, so for relatvely sparse graphics it's ideal.
_________________
(Steve Henley)
Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Feb 21, 2012 8:20 am    Post subject: Reply with quote

Paul or Eddie,

Further to my previous post, could I ask:
1) Does the '%gr[user_surface]' allow the direct addressing pointer to change when select_graphics_object@ selects a virtual window ?
2) Would you expect that a DIB interface (with the selected graphics object) could perform at a similar speed to direct addressing, especially in comparison to the draw_point@ and Draw_Line_Between@ update approach.

It appears that there is a 2048 X limit with the DIB interface. Are you able to identify any possible limit in this area.

If user_surface does not support addressing the virtual screen, DIB may be a more flexible alternative. And, if DIB is significantly slower, I may need to use both.

I would appreciate any advice you may be able to provide.

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Wed Feb 22, 2012 1:23 pm    Post subject: Reply with quote

I have managed to find a 2048 limit (in two places) and the limit proves to be avoidable. So this problem has now been fixed for the next release of salflibc.dll.

Regarding John's questions 1 and 2, currently user_surface has its own unique direct addressing pointer which cannot be changed (the whole thing is rather complex so I cannot be 100% sure that I am providing the correct answer to the question that you ask).

draw_point@ and draw_line_between@ provide interfaces into the API SetPixel and MoveTo and LineTo but I don't know how these functions perform in comparison with direct addressing.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Thu Feb 23, 2012 1:29 am    Post subject: Reply with quote

Paul,

Thank you very much for identifying this limit. It will make DIB more flexible.

I have recently been reviewing the way I manage my graphics information using Clearwin+ and am finding I don’t fully understand what the limitations are for some methods.
Some functionality I am mixing includes:
• I have my own hidden line painting window (X,Y,Z,C), which I “dump” to the selected graphics window. This has to be managed when including text.
• I have introduced screen window resizing, which I understand requires new memory allocation for the resized window.
• I use both the screen window and other virtual windows via create_graphics_region@ and select_graphics_object@ .
• I am now scanning the selected window to check the colour tablet being used for .gif dumps.

My %gr call has expanded to:
i = winio@ ('%`^gr[grey, user_resize, rgb_colours, full_mouse_input, user_surface]&', &
1024, 768, & ! screen dimension when not maximised
ptr_RGB_Address, & ! screen address for rgb surface ( not sure of the order ? )
w_handle, & ! supplied window handle defined in crtstart
mouse_back_func) ! ^ call back function for mouse and resize

It appears to me that “user_surface” points to a bgr storage format, while DIB points to a rgb_format. For user_surface, each row is stored in an integer*4 vector in blue green red order, while DIB uses a simpler integer*1 (3,h,v) format in rgb order. Have I got this right? If I have, what storage format do create_graphics_regions use?

Some things I do not understand, related to this are:
As there are a lot of legacy colour formats, is the screen window always stored in memory, or does this require rgb_colours or user_surface ?
Does “ptr_RGB_Address”, which is a memory byte address, point to the screen information or the select_graphics_object ?
Do legacy colour formats influence answers to these questions, making the memory management more complex?

Would it be possible to have a routine like:
get_select_graphics_object_address@ (Byte_Address, WIDTH, HEIGHT, NBBP, ERCODE )
where “NBBP” (the number of bits per pixel) could be expanded to indicate the memory storage format, if required.
Depending on the answers to questions above, this may be a useful addition.
It may create a faster alternative to RECOVER_DIB_BLOCK@, allowing direct addressing of the selected graphics object.

The help file on “Direct manipulation of the graphics surface” also refers to use of window_update@ and GdiFlush(). Would the use of these calls be necessary in a Windows XP or 7 environment? My suggested routine may conflict with these calls.

I would appreciate what advice you are able to provide.

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Thu Feb 23, 2012 10:02 am    Post subject: Reply with quote

Having already spent a great deal of time fixing the problem of the limit and given the complexity of the library and of your questions, I find it very difficult to provide any insight for you.

I am aware of changes in the rgb and grb order depending on the context. The only comment I can add at the moment is to note that I did find it helpful to look at the PARRAY by viewing the memory with SDBG.

I hope that you will understand that there is always one more question after the last and there are many demands upon my time.
Back to top
View user's profile Send private message AIM Address
silicondale



Joined: 15 Mar 2007
Posts: 243
Location: Matlock, Derbyshire, UK

PostPosted: Thu Feb 23, 2012 10:19 am    Post subject: Many thanks Reply with quote

Thanks to Paul for identifying the reported problem - and huge thanks also to John for the detailed investigation! I think I now have a couple of workable solutions for the immediate future - indeed three workable solutions if the new salflibc.dll will remove the 2048 X limitation.

In summary -
* I can generate SVG which operates entirely independently of the Clearwin+ graphics and generates externally viewable graphics files - but not as standard images like jpeg or gif. Based on coding in the public domain I am now building my own simple SVG library which ultimately may be useful to make generally available, as it seems there isn't one already (well there is a Fortran SVG library from FENIA but at first glance this one seems unnecessarily complex).

* Using the Clearwin+ graphics enbvironment I can directly export GIF files without the 2048 x-pixels limit, using the current salflibc.dll

* If the the next salflibc.dll removes the limit, then I can use this to generate jpg files too.

I understand John's further questions and agree that it would be good to know in more detail just how the Clearwin+ graphics works, but I think that is the subject for another discussion thread!
_________________
(Steve Henley)
Back to top
View user's profile Send private message Visit poster's website
DanRRight



Joined: 10 Mar 2008
Posts: 2815
Location: South Pole, Antarctica

PostPosted: Mon Apr 16, 2012 5:11 pm    Post subject: Reply with quote

I do not like the mess around GIFs patented functionality but it is still good to create animations from numerical simulations for Powerpoint presentations.

Question to Paul:
Clearwin+ can now take GIF files as a resource. Any chance we will get put_dib_block@ to save in GIF format?

Question to ALL:
-Do you know library which we can call from Fortran to automate creation of living GIFs ?
-and Fortran callable library which transforms pcx (or BMP which are lossless format in Clearwin suitable for animation purposes) into gif? (i have used one 20 years ago with DOS and Salford FTN77 call to DOS prompt)

Question to OP:
Can SVG do the functionality of living gifs?
Back to top
View user's profile Send private message
silicondale



Joined: 15 Mar 2007
Posts: 243
Location: Matlock, Derbyshire, UK

PostPosted: Mon Apr 16, 2012 7:32 pm    Post subject: Reply with quote

Hello, Dan - I'm not an expert on graphics formats, but when researching it, I'm sure I saw some animated SVG images. The real beauty of SVG, though, is that it's an open XML format that requires no special coding to export - you just use ordinary Fortran sequential writes. I've put together a small subroutine library that does what I need, and happy to send you a copy, or there are a couple of published fortran SVG libraries (source available free on the web) though these are both much more complex (and comprehensive) than I needed.
-Steve
... ps - just googled and got this -
http://en.wikipedia.org/wiki/SVG_animation
which answers your question, I think!
_________________
(Steve Henley)
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Mon Apr 16, 2012 9:57 pm    Post subject: Reply with quote

Dan

There is an undocumented routine EXPORT_GIF@ which has the same arguments as EXPORT_BMP@. The interface is

Code:
C_EXTERNAL EXPORT_GIF@ '__export_gif'(VAL,INSTRING,REF)
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Apr 17, 2012 12:57 am    Post subject: Reply with quote

Dan,

I do not know what "living GIFs" are, but I do create single .gif images using the following code.
Code:
    Subroutine Dump_gif_func (message, prefix)
!
!  dumps a gif file from active selected region
!
!    use mswin
    include <clearwin.ins>
    include <JDC_menu.ins>
!
    C_EXTERNAL IMPORT_GIF@            '__import_gif' (INSTRING,REF) :INTEGER*4
    C_EXTERNAL EXPORT_GIF@            '__export_gif' (VAL,INSTRING,REF)
    C_EXTERNAL WRITE_GRAPHICS_TO_GIF@ '__write_graphics_to_gif' (INSTRING,REF)
!
    integer*4 error_gif, file_nn, nx, ny
    character file_gif*80, message*(*), prefix*(*)
    integer*4 ncol, rgb_values(1024)
    data file_nn / 0 /
!
!    develop a screen dump file name
!
      call get_next_dump_file (file_nn, file_gif, prefix, '.gif')
       if (file_nn > 999) then
         error_gif = 1
         goto 100
       end if
!
      call write_graphics_to_gif@ (file_gif, error_gif)
!
  100 call get_graphical_resolution@ ( nx, ny )
      write (98,1000) file_gif, nx, ny, error_gif
!z    write ( *,1000) file_gif, nx, ny, error_gif
 1000 format ('gif DUMP file ',a,  &
              ' Size :',i6,' x',i6,' (error=',i4,')')
!
      if (error_gif == 0) then
         message = 'gif dump to '//file_gif
      else if (error_gif == 1) then
         message = 'Unable to open '//file_gif
      else if (error_gif == 3) then
         message = 'Unable to dump to '//file_gif
      else
         message = 'Unable to use '//file_gif
      end if
!
!zz      call report_region_colours      !   Test of colours on screen
!
      call get_screen_colour_table (ncol, rgb_values)
!
      end subroutine Dump_gif_func
 

The existing routines use a fixed 256 colour table. I am at present working with Robert at Silverfrost to provide a more flexible colour table, which has been the basis of all my recent questions about direct addressing. The functionality will be to put the colour table review before the .gif dump, possibly revising both the colour table that is used by the .gif dump and revising the screen colours to a reduced 256 colour set. I am going to get this working with a DIB interface and see how well it works.

John
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2815
Location: South Pole, Antarctica

PostPosted: Tue Apr 17, 2012 2:44 am    Post subject: Reply with quote

Great that gif export is there.

I had in my code outputs in BMP & PCX already programmed in and adding GIF option was just 1 min work. I also added c_external declaration but by some reason the output creates the file of zero size...BMP and PCX work fine. What the heck this could be? An older Salflibc ?

"Living gif" i've heard people call GIF89a (or something like that) standard for animated gif files . Living GIF is still used because uses 8bits per color instead of 24 which is useful to reduce size when compressed. Here is an example
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Tue Apr 17, 2012 7:22 am    Post subject: Reply with quote

All of the gif stuff has been in salflibc.dll for a long time but not exposed because of earlier copyright limitations.
Back to top
View user's profile Send private message AIM Address
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Tue Apr 17, 2012 10:13 am    Post subject: Reply with quote

A very simple way to export to GIF is the (also undocumented?) function EXPORT_IMAGE@(file_name). The output format is given by the extension of the file name (BMP, PCX, JPG or GIF).

Quote:
INTEGER FUNCTION EXPORT_IMAGE@(file_name)
CHARACTER*(*) file_name

file_name is the name of a file. The file name extension determines the type of image file to be created and must be one of: .jpg, .jpeg, .bmp, .pcx (or .gif!). The function returns a non-zero value when successful.


and

Quote:
The quality of a JPEG image exported by EXPORT_IMAGE@ can be changed by calling the new function SET_JPEG_QUALITY@ as follows:

REAL*8 FUNCTION SET_JPEG_QUALITY@(Q)
REAL*8 Q

Q is an input value in the range from 0.01D0 to 1.0D0 (use steps of 0.01). The function returns the old value should you wish to restore it afterwards. The default value of Q is 0.75D0.


Citations from cwplus.enh

Regards - Wilfried
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2815
Location: South Pole, Antarctica

PostPosted: Tue Apr 17, 2012 8:21 pm    Post subject: Reply with quote

Your way of GIF creation works, Wilfried. I do not know what's wrong with the other way...may be something is corrupt in my code. Thanks to all anyway, will find the bug eventually.

John, How specifically do you think palettes have to be implemented with only 256 colors so that it wil be simple to use them? 6R * 6G * 6B + 40?

Also, do anyone know the utilities which already implemented different palettes for 24bit RGB so that you change value from 0 to 1 and the color goes from darker end of palette to bright one? I have done several my own like those ones but will be happy to get something new too. here red palette is very simple, but rainbow already need some programming. Or may be somebody realized something like "Universal Clearwin Palette Builder" when you can make arbitrary ones with just few mouse clicks?

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group