1. Win32Lib - Create Pixmap in 24bits
- Posted by Dave Probert <zingo at purpletiger.com> Oct 29, 2004
- 552 views
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.
2. Re: Win32Lib - Create Pixmap in 24bits
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 29, 2004
- 470 views
- Last edited Oct 30, 2004
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
3. Re: Win32Lib - Create Pixmap in 24bits
- Posted by Dave Probert <zingo at purpletiger.com> Oct 30, 2004
- 492 views
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?
4. Re: Win32Lib - Create Pixmap in 24bits
- Posted by Dave Probert <zingo at purpletiger.com> Oct 30, 2004
- 459 views
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??
5. Re: Win32Lib - Create Pixmap in 24bits
- Posted by Tommy Carlier <tommy.carlier at telenet.be> Oct 30, 2004
- 483 views
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
6. Re: Win32Lib - Create Pixmap in 24bits
- Posted by Dave Probert <zingo at purpletiger.com> Oct 30, 2004
- 470 views
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> {{{