This site is no longer active and is available for archival purposes only. Registration and login is disabled.

How can I load bitmap from memory??


How can I load bitmap from memory??

Postby cat48 » Apr 19, 2002 @ 8:56am

Hi ^^

Thanks for last time reply..
I have a another question..
I want to load png files..
I already got a Bitmap handle, BITMAPINFOHEADER and raw data from png file.
ann then I tried Loadbitmap(resourceID, BITMAPINFOHEADER, data), But it didn't work.
and if bitsperpixel value is 16, Loadbitmap return 0.
Plase Help me :cry:

CCompImage* m_pImage; // Compressed Image
m_pImage = new CCompImage;
HBITMAP hBitmap = NULL;

m_pImage->Load(dc.GetSafeHdc(), _T("xxx.png"));
hBitmap = m_pImage->GetBitmapHandle();

CBitmap m_bitmap;
m_bitmap.Detach();
m_bitmap.Attach(hBitmap);

BITMAP bm;
m_bitmap.GetBitmap(&bm);

PBITMAPINFO bi = CreateBitmapInfoStruct(hBitmap);

if(!m_pGapi->LoadBitmap(m_backMap.m_ImgMap, &bi->bmiHeader, (BYTE*)bm.bmBits))
return FALSE;
cat48
 


bmp file....

Postby cat48 » Apr 19, 2002 @ 11:11am

This Source is not work, too.
So I don't know exactly that what's wrong..
When I Run LoadBitmap Function, and "Access Violation Error!!!1"

Please Help me

CFile file;
if (!file.Open(_T("\\My Documents\\xxx.bmp"), CFile::modeRead))
return FALSE;


DWORD dwFileStart = file.GetPosition();

BITMAPFILEHEADER BmpFileHdr;
int nBytes;
nBytes = file.Read(&BmpFileHdr, sizeof(BmpFileHdr));
if (nBytes != sizeof(BmpFileHdr))
{
TRACE0("Failed to read file header\n");
return FALSE;
}

BITMAPINFOHEADER BmpInfo;
nBytes = file.Read(&BmpInfo, sizeof(BITMAPINFOHEADER));
if (nBytes != sizeof(BITMAPINFOHEADER))
{
TRACE0("Failed to read BITMAPINFOHEADER\n");
return FALSE;
}

// Check that we have a real Windows DIB file.
if (BmpInfo.biSize != sizeof(BITMAPINFOHEADER))
{
TRACE0(" File is not a Windows DIB\n");
return FALSE;
}

// Allocate the memory for the bits and read the bits from the file.
BYTE* pBits = (BYTE*) malloc(nBitsSize);
if (!pBits)
{
TRACE0("Out of memory for DIB bits\n");
return FALSE;
}

// Seek to the bits in the file.
file.Seek(dwFileStart + BmpFileHdr.bfOffBits, CFile::begin);

// read the bits
nBytes = file.Read(pBits, nBitsSize);
if (nBytes != nBitsSize)
{
TRACE0("Failed to read bits\n");
free(pBits);
return FALSE;
}

// Everything went OK.
BmpInfo.biSizeImage = nBitsSize;

if(!m_pGapi->LoadBitmap(m_backMap.m_ImgMap, &BmpInfo, pBits))
return FALSE;
free(pBits);
cat48
 


Postby CapesDev » Apr 22, 2002 @ 2:49am

CapesDev
 


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron