|
-
December 27th, 2009, 03:48 PM
#1
Image overlay from stream not working
Hi everyone
I have a few PNG files, with transparency and are of the same dimension that I would like to overlay.
So far, I'm using this kind of code and it seems to be working fine:
Code:
bg = New Bitmap(My.Resources.blue)
g = Graphics.FromImage(bg)
overlay = New Bitmap(tree.Image)
g.DrawImage(overlay, 0, 0)
However, the third image to be overlapped is based on a user's input into a text box. For now, assume that an image exists for any user's input text.
I do this:
Code:
Dim stream As IO.Stream = Nothing
Dim path As String = Assembly.GetName().Name.ToString() + "." + inputbox.text + ".png"
stream = Assembly.GetManifestResourceStream(path)
If I now try to overlay the stream:
Code:
overlay = New Bitmap(stream)
g.DrawImage(overlay, 0, 0)
It doesn't work (the overlay doesn't seem to do anything)
If I do this instead:
Code:
overlay = New Bitmap(My.Resources._5)
g.DrawImage(overlay, 0, 0)
The overlay does work.
Why is this happening? I would like to use the stream method, because the image to overlay is dependant on the user input.
Edit:
Poking around, I found that if the bitmap was read from the stream, the overlay did actually work. However, the image in the overlay appeared to be larger than the true size of that image. Somehow, the stream appears to be increasing the size of the image (even though the debugger doesn't appear to show that).
I'm now even more confused as to what's going on
Last edited by aommaster; December 27th, 2009 at 06:53 PM.
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
|