Copy multiple regions from source dib to destination dib

Ramon
2013-11-23
2013-11-27
  • Ramon

    Ramon - 2013-11-23

    Hello,

    Is there a way to copy multiple regions from one dib to another? I've looked throughout the docs and couldn't find a function that allows me to lock a region of a dib, so that I may copy out the pixel data from that region. I thought FreeImage_Copy was the answer, but that does just one region.

    Let's say I have this function...

    Copy(const Rectangle& sourceRegion, FIBITMAP sourceDib, FIBITMAP destDib)
    {
    // Somehow lock the region in sourceDib by sourceRegion.

    for (int y = 0; y < sourceRegion.Height; ++y)
    {
        for (int x = 0; x < sourceRegion.Width; ++x)
        {
            // Copy pixel data from sourceDib to destDib based on the locked region.
        }
    }
    

    }

    Then in a loop I'm calling Copy...

    for (int x = 0; x < numRegions; ++x)
    {
    Rectangle sourceRegion = GetRegion(x);
    Copy(sourceRegion, sourceDib, destDib);
    }

    In the end I would have all of the copied regions from the source DIB in the destination DIB. Has anyone done something like this before? Thanks!

     
  • Hervé Drolon

    Hervé Drolon - 2013-11-25

    Hi,

    I'm sorry but I don't understand your problem ...
    Your pseudo-code looks OK so what do you want to do that cannot be solved by this code ?

    Hervé

     
  • Ramon

    Ramon - 2013-11-25

    What I need is a way to lock a region in a dib, so as I'm looping through the height and width, I'm only dealing with that region. I may have just figured this out as I'm typing this. If I use FreeImage_Copy to copy out the region I need from the source dib and store that in a temp dib, I could then copy over the pixel data from the temp dib to the destination dib and move to the next line to be ready for the next region. Think that would work? Thanks for responding. Sometimes you have to get something out and wait for someone to respond before the light bulb turns on ;).

     
  • Ramon

    Ramon - 2013-11-27

    Ok, so I was able to utilize FreeImage_Copy and FreeImage_Paste to extract out all of the regions that I need from a bitmap and merge them in with the destination bitmap. There was no need to copy the bitmap data pixel by pixel.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks