Page 1 of 2
Posted: Wed Nov 20, 2002 4:15 pm
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.
hidiho...
someone an idea, how to display an loaded image (for example an red cirle on a bmp let us say x/y 128x128 bitmap size with background color RGB 50,50,50) to a window?
I know there is following command:
"ImageGadget(#Gadget, x, y, width, height, ImageID [, Flags])"
But this command will show the image (red ball) with the not wanted background (RGB 50,50,50)... Is there any way to display only this red ball with a transparent background color to the window???
I think there must be a way to use a mask for this!? If so, how does it works? Many thanks in advance...
PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
Posted: Thu Nov 21, 2002 12:46 am
by BackupUser
Restored from previous forum. Originally posted by PB.
> Is there any way to display only this red ball with a transparent
> background color to the window???
Not with the built-in image library. Maybe there's a way using API
routines, but I don't know anything about that. If your images are
small, you can use icons with transparency... but your images would
have to be 32x32 pixels or less.
Alternatively, and I haven't tried this, you could try using a GIF image
with transparency with the WebBrowser control? Similar to this:
http://www.curvesoftware.co.uk/purebasi ... IC_ID=2139
Posted: Thu Nov 21, 2002 12:58 am
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.
hi pb
thanks for your answer! My image is a big one and i dont want to use any WebGadget trick or any other stuff to display just only a simple image (logo) on a window
hi Fred..
What about an adv. command like:
ImageGadget(#Gadget, x, y, Breite, Höhe, ImageID, [, ImageMaskID, Flags]) ???
ImageMaskID is the one color mask of the ImageID you will display on the window. If you dont have a mask just write -1 else you can define from image number 0 to image number x, which mask you want to use. What do you think?
@ all
Have someone an idea with a small working example how to manage the topic problem with API ?
Thanks in advance
PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
Posted: Thu Nov 21, 2002 1:08 am
by BackupUser
Restored from previous forum. Originally posted by PB.
> My image is a big one and i dont want to use any WebGadget trick
> or any other stuff to display just only a simple image (logo) on a
> window
Maybe use 4 icons positioned as a square?

Posted: Thu Nov 21, 2002 8:48 am
by BackupUser
Restored from previous forum. Originally posted by Froggerprogger.
errrrrrrmmmmm, did I misunderstood you, or is it possible to solve your problem with loading the file as a sprite?
Then set the mask-Color with TransparentSpriteColor() and display it with DisplayTransparentSprite().
Or do you want to see the desktop through the window?
Purebasic - what a nice name for a girl-friend
Posted: Thu Nov 21, 2002 7:54 pm
by BackupUser
Restored from previous forum. Originally posted by Justin.
Try this:
hbitmap=LoadImage_(0,"yourbitmap.bmp",#IMAGE_BITMAP,0,0,#LR_LOADFROMFILE|#LR_LOADTRANSPARENT|#LR_LOADMAP3DCOLORS)
ImageGadget(#Gadget,x,y,width,height,hbitmap)
Posted: Thu Nov 21, 2002 10:28 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> hbitmap=LoadImage_(0,"yourbitmap.bmp",#IMAGE_BITMAP,0,0,#LR_LOADFROMFILE|#LR_LOADTRANSPARENT|#LR_LOADMAP3DCOLORS)
> ImageGadget(#Gadget,x,y,width,height,hbitmap)
Thanks for that, Justin -- it works great!

Posted: Fri Nov 22, 2002 12:15 am
by BackupUser
Restored from previous forum. Originally posted by Justin.
i forgot to say that the code takes the first bitmap pixel color and converts that color in the bitmap to COLOR_3DFACE, look at the api for more info.
Posted: Wed Feb 26, 2003 12:06 am
by BackupUser
Restored from previous forum. Originally posted by mindplay.
Unfortunately this doesn't work if you have something in the background that isn't a fixed color, such as a pattern, or another bitmap etc.
I found this in the Windows API:
BOOL TransparentBlt(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int hHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
UINT crTransparent // color to make transparent
);
Looks like just the thing - it makes a single color transparent while blitting an area. But how do you get device context handles (HDCs) for, e.g., your WindowOutput, ScreenOutput etc., to pass to that function?
Posted: Wed Feb 26, 2003 8:40 am
by BackupUser
Restored from previous forum. Originally posted by fred.
I tough I missed this one but in fact it's only present for win2k+ or Win98+. Seems like MS has seen it was needed an really a pain to do with standard API. It's planned tough, I will add this feature soon.
Fred - AlphaSND
Posted: Wed Feb 26, 2003 10:47 am
by BackupUser
Restored from previous forum. Originally posted by Kale.
is there anyway to do this using alpha transparencies so you dont get a hard edge around your image, and is it possible using normal windows not windowed screens using sprites?
--Kale
In love with PureBasic! 
Posted: Wed Feb 26, 2003 11:12 am
by BackupUser
Restored from previous forum. Originally posted by mindplay.
Again, in Win2000/98 and up, there's an API call for this:
BOOL AlphaBlend(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of upper-left corner
int nYOriginDest, // y-coord of upper-left corner
int nWidthDest, // destination width
int nHeightDest, // destination height
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of upper-left corner
int nYOriginSrc, // y-coord of upper-left corner
int nWidthSrc, // source width
int nHeightSrc, // source height
BLENDFUNCTION blendFunction // alpha-blending function
);
I wouldn't recommend it though - it's slow, like most Microsoftwarez

... for that matter, I wouldn't recommend using the TransparentBlt API call - it's probably slow as well ... someone should write these functions in ASM - I don't know how to do that myself, and the API calls were just my desperate last resort...
Posted: Wed Feb 26, 2003 11:58 am
by BackupUser
Restored from previous forum. Originally posted by Justin.
you can always try to use an icon , they have a transparent color. there are tools that convert bitmaps into icons but i don't know if icons have a size limit.
then you use the drawiconex api.
Posted: Wed Feb 26, 2003 2:02 pm
by BackupUser
Restored from previous forum. Originally posted by mindplay.
that would be fine if everyone were using 32x32 images, I suppose - I'm not

Posted: Wed Feb 26, 2003 2:27 pm
by BackupUser
Restored from previous forum. Originally posted by Justin.
i think the max icon size is 128x128 32bit color. although drawiconex can scale the icon to any size.