Results 1 to 14 of 14

Thread: [RESOLVED] Image Processing, combine bitmaps

  1. #1

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Resolved [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
    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)

    2 idiots don't make a genius.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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
    Last edited by Atheist; Apr 14th, 2009 at 02:07 PM.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  4. #4

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Image Processing, combine bitmaps

    Quote Originally Posted by kleinma View Post
    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)

    2 idiots don't make a genius.

  5. #5

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.
    Attached Images Attached Images  
    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)

    2 idiots don't make a genius.

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  8. #8

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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
    Attached Images Attached Images  
    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)

    2 idiots don't make a genius.

  9. #9
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  10. #10

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.
    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)

    2 idiots don't make a genius.

  11. #11
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  12. #12

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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!"
    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)

    2 idiots don't make a genius.

  13. #13
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

  14. #14

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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....
    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)

    2 idiots don't make a genius.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width