[RESOLVED] Image Processing, combine bitmaps
All,
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
Re: Image Processing, combine bitmaps
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 :blush:
Re: Image Processing, combine bitmaps
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.
Re: Image Processing, combine bitmaps
Quote:
Originally Posted by
kleinma
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
1 Attachment(s)
Re: Image Processing, combine bitmaps
I need to start with 2 images and end up with a single image to combine them both. See my paintbrush example.
Re: Image Processing, combine bitmaps
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.
Re: Image Processing, combine bitmaps
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.
1 Attachment(s)
Re: Image Processing, combine bitmaps
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
Re: Image Processing, combine bitmaps
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.
Re: Image Processing, combine bitmaps
OK thanks for all that guys.
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.
Re: [RESOLVED] Image Processing, combine bitmaps
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.
Re: [RESOLVED] Image Processing, combine bitmaps
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!"
Re: [RESOLVED] Image Processing, combine bitmaps
I would have just told him then he needs to invest the same amount of money into the project that google does into search ;)
Re: [RESOLVED] Image Processing, combine bitmaps
That was one of a long list of things I wanted to tell him. He got fired a year later, so I suppose I can take solice in that....