Arranging more than one image having transparent pixels....
-
Here, I have two images.... both of which has transparency in it.... They look a bit like this.... http://img167.imageshack.us/img167/1263/piece00.png http://img129.imageshack.us/img129/9712/piece03.png Language I am coding in is C#. I am trying to overlap these two images(or the puzzle pieces) such that the result looks like that they fit into one another..... I have tried all sorts of things to do it but failed. I have put these 2 images into 2 pictureboxes and set the backcolor as transparent but tht didnt worked.... code:
PictureBox[] p = new PictureBox[2];
p[0] = new PictureBox();
p[1] = new PictureBox();
p[0].BackColor = Color.Transparent;
p[1].BackColor = Color.Transparent;
p[0].Size = new Size(100, 100);
p[1].Size = new Size(100, 100);
p[0].Location = new Point(100, 100);
p[1].Location = new Point(180, 100);
p[0].Image=(imageList1.Images[0]);
p[1].Image=(imageList1.Images[1]);
p[0].Visible = true;
p[1].Visible = true;this.Controls.Add(p\[1\]); this.Controls.Add(p\[0\]); p\[0\].Refresh(); p\[1\].Refresh(); p\[0\].Update(); p\[1\].Update();
I have also tried doing the same with buttons using:
button1.BackgroundImage=image1;
button2.BackgroundImage=image2;But both pictureboxes and buttons resulted in something like this: http://img148.imageshack.us/img148/5701/try1.jpg[^]
-
Here, I have two images.... both of which has transparency in it.... They look a bit like this.... http://img167.imageshack.us/img167/1263/piece00.png http://img129.imageshack.us/img129/9712/piece03.png Language I am coding in is C#. I am trying to overlap these two images(or the puzzle pieces) such that the result looks like that they fit into one another..... I have tried all sorts of things to do it but failed. I have put these 2 images into 2 pictureboxes and set the backcolor as transparent but tht didnt worked.... code:
PictureBox[] p = new PictureBox[2];
p[0] = new PictureBox();
p[1] = new PictureBox();
p[0].BackColor = Color.Transparent;
p[1].BackColor = Color.Transparent;
p[0].Size = new Size(100, 100);
p[1].Size = new Size(100, 100);
p[0].Location = new Point(100, 100);
p[1].Location = new Point(180, 100);
p[0].Image=(imageList1.Images[0]);
p[1].Image=(imageList1.Images[1]);
p[0].Visible = true;
p[1].Visible = true;this.Controls.Add(p\[1\]); this.Controls.Add(p\[0\]); p\[0\].Refresh(); p\[1\].Refresh(); p\[0\].Update(); p\[1\].Update();
I have also tried doing the same with buttons using:
button1.BackgroundImage=image1;
button2.BackgroundImage=image2;But both pictureboxes and buttons resulted in something like this: http://img148.imageshack.us/img148/5701/try1.jpg[^]
have you tried this? draw both images on to the same bitmap and display them in a picture box more like this, Bitmap=bmp new Bitmap(100,100); Graphics gr=Graphic.FromImage(bmp); gr.DrawImage(img1,0,0,... gr.DrawImage(img2,0,0,... PictureBox p=new PictureBox(); p.Image=bmp; Might work!!! GoodLuck
-
have you tried this? draw both images on to the same bitmap and display them in a picture box more like this, Bitmap=bmp new Bitmap(100,100); Graphics gr=Graphic.FromImage(bmp); gr.DrawImage(img1,0,0,... gr.DrawImage(img2,0,0,... PictureBox p=new PictureBox(); p.Image=bmp; Might work!!! GoodLuck
Yes I have tried tht... but it didnt work as it was also putting the transparent pixels also in the bmp formed...and i was skipping the transparent pixels than it was also skipping the transparent pixels at the bottom of the image... Isnt there any image container tht let see through the image on to the image behind it.... ofcourse picturebox and button isnt working or am I doing something wrong?
-
Here, I have two images.... both of which has transparency in it.... They look a bit like this.... http://img167.imageshack.us/img167/1263/piece00.png http://img129.imageshack.us/img129/9712/piece03.png Language I am coding in is C#. I am trying to overlap these two images(or the puzzle pieces) such that the result looks like that they fit into one another..... I have tried all sorts of things to do it but failed. I have put these 2 images into 2 pictureboxes and set the backcolor as transparent but tht didnt worked.... code:
PictureBox[] p = new PictureBox[2];
p[0] = new PictureBox();
p[1] = new PictureBox();
p[0].BackColor = Color.Transparent;
p[1].BackColor = Color.Transparent;
p[0].Size = new Size(100, 100);
p[1].Size = new Size(100, 100);
p[0].Location = new Point(100, 100);
p[1].Location = new Point(180, 100);
p[0].Image=(imageList1.Images[0]);
p[1].Image=(imageList1.Images[1]);
p[0].Visible = true;
p[1].Visible = true;this.Controls.Add(p\[1\]); this.Controls.Add(p\[0\]); p\[0\].Refresh(); p\[1\].Refresh(); p\[0\].Update(); p\[1\].Update();
I have also tried doing the same with buttons using:
button1.BackgroundImage=image1;
button2.BackgroundImage=image2;But both pictureboxes and buttons resulted in something like this: http://img148.imageshack.us/img148/5701/try1.jpg[^]
Maybe this will help. How to Use Transparent Images and Labels in Windows Forms[^]
Vitaliy Tsvayer Tikle