|
-
August 8th, 2012, 10:28 PM
#3
Re: Picturebox transparent on Picturebox, Panel,... it can be?
 Originally Posted by TheGreatCthulhu
It's possible but it's a bit complicated, and a bit advanced ( and a bit hackish on top of that) so if you just want to compose several transparent pictures, it's better to ditch the picture box control, and draw the images directly onto the form's surface one on top of the other, back to front.
The Graphics class you were using in your ellipse program can draw images as well. You can use, for example, DrawImage(Image, int, int), or DrawImage(Image, Rectangle) to draw a bitmap. The Bitmap class derives from the Image class, so DrawImage will accept it. You can do this in the Paint event handler. For example:
Code:
//some member variables, initialized elsewhere
private Bitmap img1;
private Point img1Location = new Point(100, 200);
private Bitmap img2;
private Point img2Location = new Point(140, 220);
//inside the Paint event handler
private void Form1_Paint(object sender, PaintEventArgs e)
{
// some other code...
e.Graphics.DrawImage(img1, img1Location); // the lowermost image
e.Graphics.DrawImage(img2, img2Location); // drawn on top of img1
// some other code...
}
Oh, that right, thank you. So, in addtion, i have a question: could i have use bitmap in graphics c#, how benefits? it smooth than on form, panel, hub????
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|