Copy Bitmap with GetPixelCnt

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2011 at 05:14, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R12 
Platform:   Windows  ; Mac  ;  Mac OSX  ; 
Language(s) :     C++  ;

---------
Hi,

i want to copy a MultipassBitmap to my own Picturefile.
Currently i use the GetPixelCnt function to get the Pixels LinePerLine, but it seems that i use it in the wrong way (on some PCs it crashs).

My Code:

  
  void *linePtr = GeAlloc(sizeX*3); // the buffer where the Pixels per line are stored  
  LONG BytesPerPixel = src->GetBt() / 8;        // src is a MultipassBitmap *  
  src->GetPixelCnt(0, y, sizeX, (UCHAR* )linePtr, BytesPerPixel, COLORMODE_RGB, PIXELCNT_0); // should copy the line to the buffer  

Is it possible what the BytesPerPixel are wrong calculated (I thought the BytesPerPixel are the Bytes used for 1 Pixel in the src Bitmap => so get the bits per pixel and take it throw 8

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2011 at 05:30, xxxxxxxx wrote:

Actually I I am not familiar with C++.
What about the GetClone() function ? If you want to Copy the Bitmap, it might be useful.

//Ah, sorry. A MultipassBitmap is not the same as a BaseBitmap. Ignore my comment. 😊

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2011 at 05:33, xxxxxxxx wrote:

well i want to copy the data to my own (RGB 8bit) Pictureclass so i couldnt clone it.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2011 at 06:27, xxxxxxxx wrote:

The BFF.cpp SDK example uses the GetPixelCnt() method.

I stripped it down to following code:

  
LONG            y,bw,bh;  
UCHAR            *line = NULL;  
  
//bm is the bitmap  
bw=bm->GetBw();  
bh=bm->GetBh();  
  
line = GeAllocType(UCHAR,3*bw);  
if (!line)   
{   
  GeFree(line);   
  return FALSE;   
}  
  
for (y=0; y<bh; y++)  
{  
  bm->GetPixelCnt(0,y,bw,line,COLORBYTES_RGB,COLORMODE_RGB,PIXELCNT_0);  
    
  // do something with line  
}  
  
GeFree(line);  

Always free the buffer with GeFree() when you are finished.

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2011 at 07:04, xxxxxxxx wrote:

ah thanks,

could i dynamical determine which COLORBYTES an COLORMODE return by getColorMode() has?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2011 at 07:31, xxxxxxxx wrote:

Originally posted by xxxxxxxx

could i dynamical determine which COLORBYTES an COLORMODE return by getColorMode() has?

Not that I know of. You have to convert COLORMODE to COLORBYTES yourself.

something like this:

  
switch (mode)  
{  
  case COLORMODE_RGB: return COLORBYTES_RGB;  
  case COLORMODE_GRAY: return COLORBYTES_GRAY;  
    
  // etc.  
    
}  

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2011 at 07:33, xxxxxxxx wrote:

ah ok
thank you very much.