Thread: Image blending

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    140

    Image blending

    Hello, I wrote a function which takes 3 bitmaps as parimeters and blends the first 2 putting the result into the third. To do so I read the rgb value from each pixel of each image, add em up and divide by 2. It works pretty well but it sure is slow, I timed it at 320x200x32 and it was like 4 blends per second. I use getpixel to get the r g b values. Is there a faster way to do this, I use allegro and djgpp.

    thanks
    Acos is good

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    anyone?

    //From Govtcheez: Don't bump threads - any more and I'll just start deleting your bumping posts... (before you ask, I'm sure anyone at fd would do the same)

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    72
    Hi

    if the two source bitmaps have the same structure (bitcount, plains, colordepth,etc.) and size, you can simply treat them as byte arrays, just adding and dividing each pair of bytes to form the resulted bitmap.

    damyan

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    So that would be faster? Ill try it out when I get home tonight.

    thanks

    oh and govt, you said that so I wouldnt B*itch about cprog right?

  5. #5
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    > oh and govt, you said that so I wouldnt B*itch about cprog right?

    Better believe it...

  6. #6
    Sayeh
    Guest
    > if the two source bitmaps have the same structure
    > (bitcount, plains, colordepth,etc.) and size, you can
    > simply treat them as byte arrays, just adding and
    > dividing each pair of bytes to form the resulted bitmap.

    Actually, it's more complex than that. In an indexed color model, such as you have described, each pixel contains a value that actually refers to an RGB triplet in a color table.

    Simply adding/subtracting pixels will not work unless the color table is organized to facility that.

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    They are truecolor bitmaps so it should work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Replies: 1
    Last Post: 05-27-2009, 12:46 PM
  3. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 12:10 PM
  4. Replies: 6
    Last Post: 03-03-2005, 03:52 AM
  5. Replies: 4
    Last Post: 03-02-2003, 09:12 AM