How to draw transparent IMAGE to Window?
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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
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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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
> 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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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
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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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
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
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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?
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?
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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...
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

-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm