Welcome, Guest. Please login or register.

Author Topic: colour pens question..  (Read 3832 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Minuous

Re: colour pens question..
« on: February 19, 2012, 11:12:36 AM »
I have a somewhat related question...
  Is there a limit of 256 pens supported by OS3.9? Because it seems that AmiDock is allocating most of those pens, and therefore my program can't allocate its pens. This happens even on eg. a 16-bit screen, where there should presumably be 65536 pens. The pen number is a LONG, but I have never seen a pen number higher than 255. The graphics.library autodoc doesn't say how many pens are supported.
  Is there some kind of workaround for this limitation that will allow my program to access pens beyond the first 256 in a cooperative way? Thanks.
 

Offline Minuous

Re: colour pens question..
« Reply #1 on: February 20, 2012, 02:58:11 AM »
>If you don't insist on exact colors, another possibility is to use shared pens, i.e. use ObtainBestPen.

It prefers to allocate them exclusively so that the user can adjust the colours themself (via the program's inbuilt palette editor). In the case where this isn't possible it will fall back to allocating them as shared pens (and it disables the palette editor in this case).

>You could check the depth of the screen's bitmap and if it is higher than 8 you need only one exclusive pen and use SetRGB32 to set the actual color before you draw.

Sorry, I don't understand how this would work...I allocate one pen, draw with it, change the colour via SetRGB32, draw with it...wouldn't the colour of the first pixel(s) already onscreen then be changed?
« Last Edit: February 20, 2012, 03:50:19 AM by Minuous »
 

Offline Minuous

Re: colour pens question..
« Reply #2 on: February 20, 2012, 06:42:27 AM »
Ah, I see now. I'll improve the program so that it uses this method on deep screens. Thanks Itex, Thomas and Piru for your help.
 

Offline Minuous

Re: colour pens question..
« Reply #3 on: February 20, 2012, 07:18:27 AM »
I replaced the call to WritePixelArray8() with SetRGB32() & WritePixel(); this works but is very slow. Presumably doing efficient >8-bit output would require CGX/P96. That's probably not worth it in the case of this particular program.