1. Win32Lib - Create Pixmap in 24bits

Hi All,
I'm trying to develop a small program that requires me to create a offscreen
pixmap using win32Lib, but it has to be in 24bit.
Currently creating a pixmap is easy, but it seems to depend on the screen colour
depth - ie if running in 256 colours then the pixmap is also 256 colours (I guess
it's a compatible DC thingy).
I'm not overly used to playing around at the low level's of Windows and have no
idea how to force the pixmap to be in 24bits, no matter what the screen is at.

I'm looking for a simple code solution rather than the inclusion of another
library.

Can anyone guide me here?

Thanks in advance.

new topic     » topic index » view message » categorize

2. Re: Win32Lib - Create Pixmap in 24bits

Dave Probert wrote:
> 
> Hi All,
> I'm trying to develop a small program that requires me to create a offscreen
> pixmap
> using win32Lib, but it has to be in 24bit.
> Currently creating a pixmap is easy, but it seems to depend on the screen
> colour depth
> - ie if running in 256 colours then the pixmap is also 256 colours (I guess
> it's a
> compatible DC thingy).  
> I'm not overly used to playing around at the low level's of Windows and have
> no idea
> how to force the pixmap to be in 24bits, no matter what the screen is at.
> 
> I'm looking for a simple code solution rather than the inclusion of another
> library.
> 

Tommy Carlier has written some 24-bit bitmap routines that work with
win32lib. Try the RDS archive.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

3. Re: Win32Lib - Create Pixmap in 24bits

Derek Parnell wrote:
> 
> Dave Probert wrote:
> > 
> > I'm looking for a simple code solution rather than the inclusion of another
> > library.
> 
> Tommy Carlier has written some 24-bit bitmap routines that work with
> win32lib. Try the RDS archive.
> -- 
> Derek Parnell

Sorry Derek, but what I was trying to achieve was a reduction in the number of
overheads in the programs, that's why I stated the requirement NOT to include
other libraries.
I'll take a look through Tommy's code though and see if it's got something close
to what I'm after.

I really would like a simple solution using just win32Lib routines - published
here would help others learn as well.
Is there a flag that can be set to say 'dont use current bit depth' - or
something like?

new topic     » goto parent     » topic index » view message » categorize

4. Re: Win32Lib - Create Pixmap in 24bits

Sorry, to clarify further on the requirements:
I've already got a bunch of functions that use the win32lib drawing routines on
a pixmap - these work splendidly.
But when detecting the colour of a pixel I get the wrong values back - due to
the different bit depth.

In Tommy's code he's dealing with DIBSections (Which don't seem to be very
compatible with the win32lib drawing functions - at least I get errors when
trying to do things and passing a dib!)
I'm not sure of the differences between Bitmap, Pixmap and DIBSection as far as
simply slotting the handle into eg. setPenColor() or drawRectangle(), etc.


As a question/suggestion, would it be sensible to see about incorporating
Tommy's win32Dib code into the win32Lib codebase as a standard.  Adjust the
drawing routines to work with DIB's as well and have an even more rather nice
package altogether??

new topic     » goto parent     » topic index » view message » categorize

5. Re: Win32Lib - Create Pixmap in 24bits

To use the Win32Lib drawing routines on a Win32Dib bitmap, you can
use the subClassControl-function to make a Pixmap-wrapper around a
Win32Dib bitmap, like this:
include win32lib.ew
include win32dib.ew

object dib
atom pixmap

dib = loadDib("bitmap.bmp")

if sequence(dib) then
    pixmap = subClassControl({Pixmap, 0}, dib[DibHandle])
    setPenColor(pixmap, Cyan)
    drawRectangle(pixmap, 1, 0, 0, 40, 40)
else
    -- the bitmap couldn't be loaded
end if


--
tommy online: http://users.telenet.be/tommycarlier
tommy.blog: http://tommycarlier.blogspot.com
Euphoria Message Board: http://uboard.proboards32.com
Empire for Euphoria: http://empire.iwireweb.com

new topic     » goto parent     » topic index » view message » categorize

6. Re: Win32Lib - Create Pixmap in 24bits

Thankyou extremely...  That fixed it perfectly.

As I didn't need all of win32dib (yet!), I just borrowed and modified the create
DIB bit, and dropped the subClassControl at the end of the little function. 
Absolutely perfect - screen independent colour handling in the background.

Thankyou again both Derek and Tommy.

Tommy Carlier wrote:
> 
> To use the Win32Lib drawing routines on a Win32Dib bitmap, you can
> use the subClassControl-function to make a Pixmap-wrapper around a
> Win32Dib bitmap, like this:
> }}}
<eucode>
> include win32lib.ew
> include win32dib.ew
> 
> object dib
> atom pixmap
> 
> dib = loadDib("bitmap.bmp")
> 
> if sequence(dib) then
>     pixmap = subClassControl({Pixmap, 0}, dib[DibHandle])
>     setPenColor(pixmap, Cyan)
>     drawRectangle(pixmap, 1, 0, 0, 40, 40)
> else
>     -- the bitmap couldn't be loaded
> end if
> </eucode>
{{{

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu