TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John
NA
1
0
Transparency showing the wrong background
Jul 13 2007 11:44 AM
Hi there, I have a form, on top of which is a rectangle filled with an image of a football pitch. When I move a player icon that has a transparent background over this pitch the transparent background on the icon shows the base color of the form rather then the football pitch. If someone could tell me how I can make the transparency show the pitch rather then the form's base colour I would be grateful.
Heres a picture of what it looks like:
http://homepage.ntlworld.com/andrew.baldock/pic.jpg
Below is the code I used:
public Form1()
{
InitializeComponent();
CenterToScreen();
beast.SizeMode = PictureBoxSizeMode.StretchImage;
beast.Location = new System.Drawing.Point(64, 32);
beast.Size = new System.Drawing.Size(38, 38);
beast.Cursor = Cursors.Hand;
beast.Image = new Bitmap("rtbeast1b.gif");
beast.MouseDown += new MouseEventHandler(beast_MouseDown);
beast.MouseUp += new MouseEventHandler(beast_MouseUp);
beast.MouseMove += new MouseEventHandler(beast_MouseMove);
Controls.Add(beast);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawImageUnscaledAndClipped(pitch, dropRect);
}
private void beast_MouseDown(object sender, MouseEventArgs e)
{
isDragging = true;
oldX = e.X;
oldY = e.Y;
}
private void beast_MouseMove(object sender, MouseEventArgs e)
{
if (isDragging)
{
if (dropRect.Contains((e.X + beast.Left), (e.Y + beast.Top)))
{
int x = (e.X + beast.Left) - dropRect.X;
int y = (e.Y + beast.Top) - dropRect.Y;
x = x / 30;
y = y / 30;
beast.Left = (x * 30) + dropRect.Left;
beast.Top = (y * 30) + dropRect.Top;
}
}
}
private void beast_MouseUp(object sender, MouseEventArgs e)
{
isDragging = false;
}
Many thanks,
John
Reply
Answers (
1
)
Graphs/Charts Help
A generic error occurred in GDI+.