I've searched these forums, and found some GDI and C# links, but I really want to do some image processing in VB.NET.
Any links on how I would go about combining 2 bitmaps into one, sort of superimposed on top of eachother? I don't know what libraries are available in .NET.
THanks!
Dave
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
You can either draw bitmap #2 directly onto bitmap #1, or you could create a 3rd bitmap and draw both #1 and #2 on there. Here's an example I've whipped together on the latter approach:
Code:
Dim bitmap1 As New Bitmap("c:\pic1.png")
Dim bitmap2 As New Bitmap("c:\pic2.png")
Dim combinedBitmap As New Bitmap(640, 480)
Using g As Graphics = Graphics.FromImage(combinedBitmap)
g.DrawImage(bitmap2, 10, 15)
g.DrawImage(bitmap1, 0, 0)
End Using
combinedBitmap.Save("c:\combined.png", System.Drawing.Imaging.ImageFormat.Png)
bitmap1.Dispose()
bitmap2.Dispose()
combinedBitmap.Dispose()
Edit: After reading kleinmas response below, I get the feeling I have misunderstood the question. I'm not sure what the word "superimposed" means, even though I looked it up in a dictionary
Last edited by Atheist; Apr 14th, 2009 at 02:07 PM.
i guess it depends on if you are talking about rectangular images or not.
Is it 2 images, that are rectangular, that you want to super impose one on top of the other? Something like that would require setting transparency on some of the pixels of the top level photo, so that the one under would show through.
If its a case of something like a non rectangular image (like a sprite) that has transparency already so that it looks no rectangular, and you just want to put that ontop of another image, then that can easily be done with standard drawing operations.
i guess it depends on if you are talking about rectangular images or not.
Is it 2 images, that are rectangular, that you want to super impose one on top of the other? Something like that would require setting transparency on some of the pixels of the top level photo, so that the one under would show through.
If its a case of something like a non rectangular image (like a sprite) that has transparency already so that it looks no rectangular, and you just want to put that ontop of another image, then that can easily be done with standard drawing operations.
Yes, they will likely be 2 rectangular images. I need to know what libraries are available to superimpose one on top of another. ie.. Image1 is a circle, and Image2 is a square. Image3 would show a circle/square. Hard to explain with text, but I think you get the idea.
Any example code using these libraries would be great, or links to same.
Thanks,
Dave
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
well for those example images, you would make the white color transparent, and draw each image ontop of a new image object (aka a blank canvas) and save the resulting image.
However if these are just your examples, and the actual images you want to combine are more complex, it may not be that simple.
What is inside of the circle? Is it the color white or is it transparency? Do you need to "make" the image that is on top transparent or does the image already contain transparency? If so you should just be able to use what I posted above.
I don't have too many details, but I will need to take an image like this, and programmatically superimpose smaller images on top of it, based on X,Y position, and R, an angle which I may have to rotate each smaller image.
What image processing libraries are available to me in VB.NET to do this?
Thanks!
Dave
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
ok, so that is basically the canvas/background, and you will take other drawings and place them on top of this canvas... like to indicate where certain things will go on that board..
I think you should be able to do this with the standard image/bitmap classes in system.drawing. Maybe if we also had a sample of what kind of image you are looking to draw on top of that, we might have some more info.
Unfortnately, I don't have any sample images yet. I just need to know what my options are in VB.NET for image processing if this job goes through and I am asked to do this. I would get more information on what all needs to happen at that time.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
well I can tell you it most certainly should be possible to do in VB
In C# you still have all the same classes, they just have an added benefit of unsafe code blocks, which can allow for faster image manipulation. I don't even know if that would really matter here though or not.
Speed should not be any issue for me, but you never know until the customer complains, right? One time we set up this assembly line to be database-driven. Not an easy task; it used RFID scanners which required 3-4 seconds just to accomplish 1 scan.
The final solution had a 45 second cycle time, and the customer demanded it should be 15 seconds, AFTER THE PROJECT WAS FINISHED.
I'll never forget his comment:
"Why can't this assembly line be as fast as a Google-search?!? You type in Google and your answer comes back in under a second! There's no reason anything should take longer than that!"
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)