Click here to Skip to main content
15,902,198 members

Comments by Ajesh Kumar.T.T (Top 3 by date)

Ajesh Kumar.T.T 19-Nov-13 8:10am View    
I am not familiar with this library. But I found similar issue while creating mp4 video files from raw image data. I used Media Foundation APIs for this purpose. In that case encoding gets failed while given RGB24 format. I solved it by converting RGB24 to RGB32 by using the manual looping.
Is this conversion is needed for image data or it for video?
Ajesh Kumar.T.T 28-Sep-12 0:19am View    
I am using GDI plus for conversion, and I tried the following code. But this does not work.

// Create a BITMAPINFOHEADER.
INT nNumColors = 256;
UINT uHeaderSize = nNumColors * sizeof( RGBQUAD ) + stBitmapInfo.bmiHeader.biSize;
INT nPaletteSize = nNumColors * sizeof( RGBQUAD );


// Bitmap Info Header
BYTE* pbyBMInfo = 0;
ITF_NEW_ARRAY( pbyBMInfo, BYTE, uHeaderSize );
ZeroMemory( pbyBMInfo, uHeaderSize );

// Fill Header
LPBITMAPINFO pstBMInfo = reinterpret_cast<lpbitmapinfo>( pbyBMInfo );
memcpy( pstBMInfo, &stBitmapInfo, sizeof( BITMAPINFOHEADER ));

RGBQUAD* pRGB = new RGBQUAD[nNumColors];
// Color table filled in pRGB.
BYTE* pbyPixelData = new BYTE[width * height];
// Pixel data filled in pbyPixelData.
Gdiplus::BitmapData RGBData;
memcpy( pstBMInfo + sizeof( BITMAPINFOHEADER ), pRGB, nPaletteSize );
pBitmapImg = new Gdiplus::Bitmap( pstBMInfo, pbyPixelData );
Gdiplus::Rect ImageRect( 0, 0, width, height );
Gdiplus::Status eRetStatus = pBitmapImg->LockBits( &ImageRect, Gdiplus::ImageLockModeRead,
PixelFormat24bppRGB, &RGBData );
if( Gdiplus::Ok != eRetStatus )
{
pBitmapImg->UnlockBits( &RGBData );
// Error case. Return
}
BYTE* pbyRgbBuffer = new BYTE[RGBData.Height * RGBData.Width * 3];
BYTE* pbyConvertedBuffer = reinterpret_cast<byte*>( RGBData.Scan0 );
for( int nRowIndex = 0; nRowIndex < RGBData.Height; ++nRowIndex )
{
int nNewBufferRowPos = nRowIndex * RGBData.Width * 3;
int nRGBRowPos = nRowIndex * RGBData.Stride;
memcpy( pbyRgbBuffer + nNewBufferRowPos, pbyConvertedBuffer + nRGBRowPos, RGBData.Width * 3 );
}
ULONG ulPixelDataSize = RGBData.Height * RGBData.Width * 3;
BYTE byNewSamplesPerPixel = 3;
pBitmapImg->UnlockBits( &RGBData );
Ajesh Kumar.T.T 27-Sep-12 2:53am View    
This is one time consuming process. Actualy I have a buffer which contains BitmapInfo + pixel data. this pixel data is in the palette format. Bitmapinfo structure contains color table. This can be solved by using LockBits method but I don't know how to use LockBits method for converting buffer to buffer. I found a lot of such conversions, but they are mainly processed one input file.