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: Wed Apr 18, 2012 7:26 am    Post subject: Reply with quote

Dan,

Robert from Silverfrost has been providing new routines to manage the colour palette for .gif files, as there are only 256 colours available in the .gif format. .gif is a very compact format that is still generally supported.
To better manage the palette, there are new routines to:
- Get the default palette,
- Update the palette, or
- Reset to the default palette
You would find that dumping the graphic you have presented above to a .gif file would result in loosing many of the close peach colours.
I am testing how to revise the colour palette by:
- importing the image to a DIB array,
- choose the 256 colours that occur most often in the display, and
- providing this colour palette, before calling write_graphics_to_gif@

I've now got the DIB importing and am now trying to choose the best palette. Hope to have this complete soon, between other crises !

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



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

PostPosted: Wed Apr 18, 2012 9:54 am    Post subject: Reply with quote

Just a remark: I don't think that the reduction of colours from 24 to 8 bits is good via selecting the 256 colours that most often occur. Perhaps it is better to implement methods like Floyd-Steinberg.

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



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

PostPosted: Thu Apr 19, 2012 12:06 am    Post subject: Reply with quote

I'd also prefer to consider (but not insist in any way) the same straightforward, transparent and simple utility like 24bit colors has:

rgb256@(ir,ig,ib) where ir,ig,ib = 0....5

It will cover 216 colors. The rest could be any preset colors like ones from 4-bit palette, black and white palette or no any.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Thu Apr 19, 2012 11:20 am    Post subject: Reply with quote

If you want substantially more than 256 colours, then .png is the updated version of .gif.
However, my graphics typically has a 128 colour palette. For some reason unknown to me, I can get an additional 100 to 800 additional colours in pixels near to text. I'm not sure of the source of this shading around text.
I've been writing a view cleanup routine to reduce the number of colours back to less than 256 and to also provide my new palette to the .gif writer. If I do a light source shading view of the surface, I have a lot of close colours, which the default .gif palette reduces to about 3 or 4 colours.
Anyway, I'm near the end of this.
My other problem with this project is that I'm using a fairly large model (20 million polygons) which is challenging the amount of free memory available. Keep getting the same types of problems in a variety of projects.

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



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

PostPosted: Fri Apr 20, 2012 4:37 am    Post subject: Reply with quote

How do you plot your 20M polygons?
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Fri Apr 20, 2012 6:42 am    Post subject: Reply with quote

Dan,
I dump them to my virtual screen where each pixel has both colour and depth. The polygons are very simple, only 3 or 4 sided, assumed as a flat surface, with colour and depth at the corners as reals. (paint each pixel on a series of straight lines) At the end of the plot I dump to the clearwin graphics region, then follow with the more difficult text etc drawn direct to the graphics region. It works realy well. Surprisingly fast. No Opengl, although I think Opengl is more suited to more complex surfaces.
Most plots are smaller, as I zoom in to pick up the detail.
Struggling with stack problems lately as I am running out of memory and the get_filtered_file@ stack error is also limiting capacity.
For motion, I first paint a series of stored views then cycle through displaying them to the screen. (Have not confirmed the available stack for this on a big model. I only have limited functionality for the realy big model, which is a surface model for the sea-bed)
Clearwin+ is very good for this.

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



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

PostPosted: Fri Apr 20, 2012 8:34 pm    Post subject: Reply with quote

I also do something similar. Clearwin and graphics libraries are really powerful and fast.

But its OpenGL just blows you out of the water. Do you see the picture i posted above with OpenGL example? I made its matrix 4500x4500 = 20M and ran the test. I do not have 20Megapixels monitor yet to put the whole 20M polygons on screen. But on 4 and 8M pixels of two-monitor screens (combined) this gigantic surface still rotates with the 20 frames per second without even hardware acceleration!
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Apr 24, 2012 1:24 am    Post subject: Reply with quote

I have progressed with the use of DIB and educated myself on some performance issues with my graphics code.
My large polygon drawing routine is a bit slower than I recalled to Dan, taking about 5 seconds to prepare polygons and paint the screen, although I've never considered the delay unacceptable. ( I might have made a mistake by choosing this as my testing example.)
As for the colour review of the screen for a .gif dump, the slowest parts are the review of the colour tablet (.13 sec) and reporting the colour palette to the OUTPUT screen (.11 sec) (surpriningly slow for a write statement) while the accessing of the DIB block is very fast (.01 sec)
I'm now only reporting results to a file.
DIB appears to be a viable alternative to direct addressing for the approach I am using.
I look forward to the /DEBUG and enlarged DIB support in the new update.

Thanks very much Paul and Robert for all your assistance with this as I have made some progress. The change to Windows 7 has resulted in much more work than I origionally intended.

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



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

PostPosted: Tue Apr 24, 2012 6:41 am    Post subject: Reply with quote

May be someone can use it: A way to reduce colours and create an 8-bit image from a 24-bit one.

Code:
c     image_1: input, 24 bits, size = rows*cols
c     image_2: output, 8 bits, same size

      integer*4     A,B,C,i,j,k,l,m,n,o,p,dsp
      real*8        r
      character*1   rgb_a(3,0:255)

c     reduce number of colours (Floyd-Steinberg method)

      dsp = 3*cols

      do i = 1,rows-1
        A = (i-1)*dsp
        B = A+dsp
        do j = 4,dsp-3,3
          do n = 0,2
            o = j+n
            k = ichar(image_1(A+o))
            if (k .gt. 0) then
              l = 50*int(k/50.)
              image_1(A+o) = char(l)
              r = dble(k-l)
              p = ichar(image_1(A+o+3))
              if (p .gt. 0) then
                C = min(p+nint(.4375*r),255)
                image_1(A+o+3) = char(C)
              end if
              p = ichar(image_1(B+o-3))
              if (p .gt. 0) then
                C = min(p+nint(.1875*r),255)
                image_1(B+o-3) = char(C)
              end if
              p = ichar(image_1(B+o  ))
              if (p .gt. 0) then
                C = min(p+nint(.3125*r),255)
                image_1(B+o  ) = char(C)
              end if
              p = ichar(image_1(B+o+3))
              if (p .gt. 0) then
                C = min(p+nint(.0625*r),255)
                image_1(B+o+3) = char(C)
              end if
            end if
          end do
        end do
        image_1(A+1)   = image_1(A+4)
        image_1(A+2)   = image_1(A+5)
        image_1(A+3)   = image_1(A+6)
        image_1(dsp  ) = image_1(dsp-3)
        image_1(dsp-1) = image_1(dsp-4)
        image_1(dsp-2) = image_1(dsp-5)
      end do

      A = (rows-2)*dsp
      do j = 1,dsp
        image_1(A+dsp+j) = image_1(A+j)
      end do

c     create colour palette

      rgb_a = char(255)
      A = 0
      do k = 0,255,63
        do l = 0,255,63
          do m = 0,255,63
            rgb_a(1,A) = char(k)
            rgb_a(2,A) = char(l)
            rgb_a(3,A) = char(m)
            A = A+1
          end do
        end do
      end do

c     create 8 bit image

      do i = 1,rows
        A = (i-1)*dsp
        B = (i-1)*cols
        do j = 1,dsp,3
          k = ichar(image_1(A+j  ))/50
          l = ichar(image_1(A+j+1))/10
          m = ichar(image_1(A+j+2))/2
          n = (j+2)/3
          image_2(B+n) = char(max(k+l+m,1))
        end do
      end do


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



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

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

There's a lot of work that has gone into this, by users - John, Wilfried, Dan - and clearly also by Silverfrost.

Quick question - will Silverfrost be documenting the GIF-related library additions and perhaps also providing some demo examples, in the next compiler update? This is something that would be extremely useful, and not only to the few who have participated in this thread.
_________________
(Steve Henley)
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Tue Apr 24, 2012 8:30 am    Post subject: Reply with quote

I have noted Steve's request and will see if the task can be fitted in before the next release.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Apr 24, 2012 9:49 am    Post subject: Reply with quote

Wilfred,

My problem has not been reducing the number of colours displayed as a general problem, but modifying the colour pallete to include the 130 rgb colours that I use in the .gif colour table.
.gif supports a set of 256 colours, which can be described as 24bit colours in a look-up table. The default set of colours provided does not support the distorted set of colours I use. I modify this set to suit my requirements.
An associated aspect of the clearwin graphics display is that when writing text, pixels near the text change their rgb values. I don't know why, but I can end up with up to 900 different rgb colour values displayed on a screen. I have been testing ways of including some of these in the palette and removing others, while remaining at the 256 limit then supply this palette to the .gif write routine.
I'm at the stage where my latest colour review attempt is the slowest part of the process, so I'm looking at an alternative/better approach to search for and change these other colours.

Thanks for your assistance with this, as I don't yet know where my final solution approach will be.

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



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

PostPosted: Tue Apr 24, 2012 10:53 am    Post subject: Reply with quote

John,

you wrote "An associated aspect of the clearwin graphics display is that when writing text, pixels near the text change their rgb values. I don't know why...".

I think the funny colours at the fonts are a result from a font smoothing process which is standard in Windows. You can de-activate it in the system settings, performance > visual effects, then something like "Smooth edges of screens fonts" (sorry, my system is in German, I don't know the exact English expression).

May be that de-activating the smoothing, the funny effect will be killed.

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



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue Apr 24, 2012 1:17 pm    Post subject: Reply with quote

I think that Wilfried is right - this is a type of anti-aliasing to improve the readability of screen fonts. If you don't want this, and cannot find a setting to turn it off (or you have users whose machine settings you have no control over) then you may have to create and/or use a "stick font" such as was used by plotters and which you can use to draw your text.

FTN77 with DBOS used to support vector stick fonts from the "Hershey" collection.

I wrote routines to draw vectors from outlines of my own, including some Greek characters. I could dig the code out. I know it works with FTN95. However, the editor for new fonts was written to use a bizzare Dodo graphics system called GSX, so the chances of creating new fonts are about nil.

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


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

PostPosted: Tue May 01, 2012 2:46 pm    Post subject: Reply with quote

Following on from Steve's request for more information about library routines for GIF images, here is a summary of what I have to date.

1) export_image@ is documented and exports from the current drawing surface to a GIF file.

2) import_image@ is documented and imports from an image file to the current drawing surface but does not currently handle GIF files and resources. I have now extended this routine so that it will display the first image of a GIF file or resource.

3) import_gif@ already exists but is not documented. It works like import_bmp@ and provides a DIB handle as in the documented example for import_bmp@ except that import_gif@ has the interface

Code:
 C_EXTERNAL IMPORT_GIF@ '__import_gif'(INSTRING,VAL,REF,REF) :INTEGER*4


where the first VAL is the integer number of the image in the file and the first REF is returned as the number of images in the file.
Back to top
View user's profile Send private message AIM Address
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 3 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