06-22-2006, 12:09 PM
Hey all. My question is this, I have a .png file for example lets call it picture.png (original huh?) and what i want to do is when i click on a button it is drawn onto the form, its transpareny and all. is this possible or will i have to use picture boxes?
thanks in advance
06-22-2006, 12:27 PM
You can use the DrawImage method of your form's graphics object to draw an image (check the GDI+ FAQ if you're unfamiliar with this: http://www.bobpowell.net/faqmain.htm). Not sure how DrawImage handles PNG transparency though...
If the transparency won't work, you can always use the MakeTransparent method of the Bitmap object to set a particular color as the transparent color.
06-22-2006, 04:32 PM
hey JNewt. thanks for the push in the right direction. I am using the Draw Image to draw onto the form but when the form opens it takes so friggin long for the image to show. Is there a way to say have it loaded then the form show?
06-22-2006, 07:45 PM
Where in the form's code are you painting the image? Generally you should use the Paint event (use the Graphics object passed in the "e" argument).
Also, don't load the image every time you paint. Declare a variable (type: bitmap) in your declarations section and then load the bitmap in the Load event of your form. Then you just need to paint it every time the form redraws.
06-23-2006, 05:09 AM
im a little confused to what you mean by declare a variable (type:bitmap). And i have fixed one problem by turning double buffering on, this solves the problem of images being loaded with the form (in the paint event) but i have a button that once clicked another image is set to be drawn. i put the coding in the button click event and when it loads it like swipes down from the top of the image to the bottom and just looks terrible. And i know it cant be my computer causing the slowness because its brand new.