Thread: Combine/Concatenate Pixels of two Image buffers to form a single image

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    3

    Unhappy Combine/Concatenate Pixels of two Image buffers to form a single image

    Hi All,
    I am concatenating TIFF images image1 and image2 of CMYK pixel format with same height. For that I am copying the pixels to Buffer1 and Buffer2 then combining the both buffers to BUFF.

    Code:
          //Image1 Dimensions 
          UINT Width = 150;
          UINT Height = 100;
    
         UINT Stride = Width  * 3 ;
    
         Stride = ((cbStride + sizeof(DWORD) - 1) / sizeof(DWORD)) * sizeof(DWORD);
          
          BYTES * Buffer1 = NULL;
          BYTES * Buffer1 = new BYTE[Stride * Height];
    
          //Here the pixels are copied to Buffer using GDI+ as follows
          //WICRect rc = { 0, 0, Width, Height };
          //piFormatConverter->CopyPixels(&rc, Stride, Stride * Height, Buffer1);
    
    
          //Image2 Dimensions 
          UINT Width2 = 150;
          UINT Height2 = 100;
    
         UINT Stride2 = Width2  * 3 ;
    
         Stride = ((Stride2 + sizeof(DWORD) - 1) / sizeof(DWORD)) * sizeof(DWORD);
          
          BYTES * Buffer2 = NULL;
          BYTES * Buffer2 = new BYTE[Stride2 * Height2];
    
          //Here the pixels are copied to Buffer using GDI+ as follows
          //WICRect rc = { 0, 0, Width2, Height2 };
          //piFormatConverter->CopyPixels(&rc, Stride2, Stride2 * Height2, Buffer2);
    
         // ...  Now I want to Combine the Pixels of Buffer1 + Buffer2  so that to create a single image using the same GDI+ method as follows.
    
         BYTE * BUFF=NULL;
         UINT BUFFSize = (Stride + Stride2) * Height;
         BUFF = new BYTE[BUFFSize];
         memcpy(BUFF,pbBuffer,(cbStride * uHeight));
         GdiPlusBitmap = new Bitmap(Width+Width2, Height, (Stride+Stride2),   PixelFormat32bppCMYK, BUFF);
    But here the combined memory through created image is black & white and not sharp.

    I hope some experts here can guide me with some work arounds.

    Thanks & Regards,

    Madhav
    Last edited by Salem; 03-08-2010 at 12:09 PM. Reason: Added [code][/code] tags - learn to use them yourself

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Imagine each image was only 1 pixel wide.

    RGBX and rgbx
    where X and x represent the padding at the end of each row to make up the multiple of 4 stride.

    Are you outputting this
    RGBrgb

    Or do you have some Xx mixed in with it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    3
    This Pixels actually CMYK

    Therefore CMYKX and cmykx with padding

    I am trying to add CMYKX + cmykx

    we need to remove the X before adding?
    then how can we do please..

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > we need to remove the X before adding?
    What do you think, based on your knowledge of the format and the results of your experiments to date?

    > then how can we do please..
    Copy a row from one image, without the xxxxx
    Append the same row from the other image, without the xxxxx
    Repeat for the win!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    3
    Thank you Salem for your kind advice. Actually Tiff image pixels which I am decoding are encoded in LZW compression. Therefore to read and encode it back need some extra effort.

    Thanks & Regards

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. Image rotation - doesn't always work
    By ulillillia in forum C Programming
    Replies: 12
    Last Post: 05-03-2007, 12:46 PM
  3. background image on form
    By luigi40 in forum C# Programming
    Replies: 0
    Last Post: 07-14-2005, 05:41 AM
  4. Replies: 4
    Last Post: 03-02-2003, 09:12 AM
  5. creating image from pixels stored in file
    By Kristian25 in forum Windows Programming
    Replies: 3
    Last Post: 01-21-2003, 02:08 PM

Tags for this Thread