Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Transparent Back NewCharacterBltSprite


Mikekan13
 Share

Recommended Posts

There's a pretty useful function that you can use to do this actually. It's called **TransparentBlt**. It's similar to **BitBlt**, but it has some extra parameters.

```
Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
```
Either keep it privately declared or publicly declare it depending on your needs. Here's the breakdown of the parameters, from left to right:

hDC - The handle device context you want to blit to. This is usually a form or a picturebox, basically
x - X-coordinate where you want the graphic on the form/picturebox
y - Y-coordinate where you want the graphic on the form/picturebox
nWidth - Width of the graphic
nHeight - Height of the graphic
hSrcDC - Picturebox or form you're obtaining your graphics from (may need to create your own picturebox and load the graphics onto it since Origins uses BltToDC)
xSrc - X-coordinate of the graphic to start loading from (Ex: Your sprite has 12 sprites on the sprite sheet, and they're all in 32 x 32 format. Putting 96 as the xSrc would start loading the 3rd sprite)
ySrc - Y-coordinate of the graphic to start loading from
nSrcWidth - You should keep this value the same as **nWidth**
nSrcHeight - You should keep this value the same as **nHeight**
crTransparent - The transparency. Place **RGB(0, 0, 0)** here, as that makes the graphic appear transparent.

Well, that's all. I hope that helps!
Link to comment
Share on other sites

@David:

> I think black shud automaticly make it transparent.. I dont remember just try

Leave this section and never come back.

@Mikekan13:

> Hey that looks great! Thank you I will give it a go.

Be careful when using that function. Old versions of Eclipse use BitBlt so much that they practically double the amount of memory used by having to load all the graphics into separate pictureBoxes to render them. It should be okay with the occasional sprite, as they're small bitmap images, but make sure you load/unload them properly.
Link to comment
Share on other sites

hmm I can't get this to work. I have tried it several different ways and it just won't blt the image at all. 
```
TransparentBlt frmMenu.picSprite, 0, 0, frmMenu.picSprite.width, frmMenu.picSprite.height, frmMenu.picSrc.Picture, 32 * 7, 0, frmMenu.picSprite.width, frmMenu.picSprite.height, RGB(4, 255, 17)
```
Edit: nm I guess this only works for picture boxes and not pictures. Still have not gotten it to do what I want but it will atleast blt the image
I also dont see how this can help me if it has to be used on a picture box. even if I make the green transparent the picture box will still show up.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...