rodneyc8063
New member
- Joined
- Nov 19, 2006
- Messages
- 4
- Programming Experience
- Beginner
I recently started to dabble in a bit of game programming for VB.net and am having a lot of problems with making the background of a picture transparent.
I have a picture of "mario" with a neon green background. Im drawing him to a "rectangle" and am attempting to make his green background transparent.
I have
Dim g as Graphics
Dim imageattributes as new system.drawing.imaging.imageattributes
In start up form
g=piconscreen.creategraphics
I want everything to be drawn to "g"
Then i actually draw mario to g
Dim mariorectangle as rectangle
mariorectangle.x=300
mariorectangle.y=300
mariorectangle.width=34
mariorectangle.height=38
g.drawimage(picmario.image, mariorectangle, 0, 0, mario.width, mario.height, system.drawing.graphicsunit.pixel, imageattributes)
Ok so at this point i have drawn the mario image to a rectangle on "g". Now i want to get rid of the green background he has so i tried to use the following code in the start up form:
Dim lowercolor as color=color.fromArgb(255, 0, 255)
Dim uppercolor as color=color.fromArgb(255, 0, 255)
imageattributes.SetColorKey(lowercolor, uppercolor, System.Drawing.Imaging.ColorAdjustType.Default)
Here, i thought i got rid of the any greens contained within the mario picture with the 0. But im still getting his background, in fact when i tried to fiddle with any of the RGB and set it all to 0, 0, 0 the picture doesnt change at all.
Any help as to how to make a specific color transparent would be greatly appreciated!!!
I have a picture of "mario" with a neon green background. Im drawing him to a "rectangle" and am attempting to make his green background transparent.
I have
Dim g as Graphics
Dim imageattributes as new system.drawing.imaging.imageattributes
In start up form
g=piconscreen.creategraphics
I want everything to be drawn to "g"
Then i actually draw mario to g
Dim mariorectangle as rectangle
mariorectangle.x=300
mariorectangle.y=300
mariorectangle.width=34
mariorectangle.height=38
g.drawimage(picmario.image, mariorectangle, 0, 0, mario.width, mario.height, system.drawing.graphicsunit.pixel, imageattributes)
Ok so at this point i have drawn the mario image to a rectangle on "g". Now i want to get rid of the green background he has so i tried to use the following code in the start up form:
Dim lowercolor as color=color.fromArgb(255, 0, 255)
Dim uppercolor as color=color.fromArgb(255, 0, 255)
imageattributes.SetColorKey(lowercolor, uppercolor, System.Drawing.Imaging.ColorAdjustType.Default)
Here, i thought i got rid of the any greens contained within the mario picture with the 0. But im still getting his background, in fact when i tried to fiddle with any of the RGB and set it all to 0, 0, 0 the picture doesnt change at all.
Any help as to how to make a specific color transparent would be greatly appreciated!!!