MFC view表示Pngピクチャ(bitmap方式表示)


ヘッダファイルを含める
#include "atlimage.h"
OnPaintでのコードは次のとおりです.
void CDialogTest::OnPaint()
{
		CBitmap bitmap;
		CDC dcMemory;
		int result;
		bitmap.CreateBitmap(IMAGER_SIZE_X, IMAGER_SIZE_Y, 1, 32, m_lpBuf);	
		
		result = bitmap.SetBitmapBits(IMAGER_SIZE_X*IMAGER_SIZE_Y*4, m_lpBuf);
		dcMemory.CreateCompatibleDC(m_pDC);
		CBitmap *pbmpOld = dcMemory.SelectObject(&bitmap);
		//m_pDC->StretchBlt(0,0,  ,  ,&dcMemory,0,0,  ,  ,SRCCOPY);
		m_pDC->BitBlt(0, 0, IMAGER_SIZE_X, IMAGER_SIZE_Y, &dcMemory, 0, 0, SRCCOPY);
		//m_pDC->StretchBlt(0,0,IMAGER_SIZE_X/2,IMAGER_SIZE_Y/2,&dcMemory,0,0,IMAGER_SIZE_X,IMAGER_SIZE_Y,SRCCOPY);
		dcMemory.SelectObject(pbmpOld);

}

画像をロードしbimap形式に変換
void CDialogTest::LoadImage()
{
	   HBITMAP hBitmap;
	   CString filename;
	   CString BMPFolder;
	   CString str;

	   CImage layerPng;

	   str.Format("layer (%d).png", layernum);
	 
	   filename = BMPFolder + "\\" + str;

	   layerPng.Load(filename);
	   hBitmap=layerPng.Detach();
	   CBitmap bmp;
	   BITMAP l_bitMap;
	   bmp.Attach(hBitmap);
	   bmp.GetBitmap(&l_bitMap);

	   int height = l_bitMap.bmHeight;
	   int width = l_bitMap.bmWidth;

	   bmp.GetBitmapBits(IMAGER_SIZE_X*IMAGER_SIZE_Y*4,m_lpBuf);
}