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
Steve Luktisch
NA
1
3.8k
Draw.image
Oct 30 2010 11:27 PM
Hello all
I am having a problem with GDI+, I'm using it to draw an image onto a form; the image has some transparent color as the background. i am using getpixel to let me know if I click on the picture or the background. this works fine until I have a tick move the picture somewhere else on the form, at this point getpixel does not work unless you click where the image was when it was first drawn. Here is the code used in the forms paint event:
bmp is declared globally so it can be used by the getpixel subroutine in the mouse down event.
Dim g As Graphics = Graphics.FromImage(bmp)
g.Dispose()
Dim attr As New ImageAttributes
' Set the transparency color key based on the upper-left pixel
' of the image.
' Uncomment the following line to make all black pixels transparent:
attr.SetColorKey(bmp.GetPixel(0, 0), bmp.GetPixel(0, 0))
' Draw the image using the image attributes.
Dim dstRect As New Rectangle(xpoint, ypoint, bmp.Width, bmp.Height)
e.Graphics.DrawImage(bmp, dstRect, 0, 0, bmp.Width, bmp.Height, _
GraphicsUnit.Pixel, attr)
Reply
Answers (
0
)
Graphicspath.addstring
GDI+ DrawLine between two imagebuttons on webpage