since all you need of gdi+ is the bitmap thing... this'll probably be easier to get to work using the CreateDIBSection() solution instead.
Create a new project.
Set the type to SDI.
Set the view type to CScrollview
Open the view header and add the following 2 members.
Code:
CBitmap m_Bmp;
DWORD* m_pdwBits;
In the OnDraw() you add this code
Code:
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
CBitmap* pOldBmp = dcMem.SelectObject(&m_bmp);
BITMAP bmpInfo;
m_bmp.GetBitmap(&bmpInfo);
pDC->BitBlt(0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,&dcMem, 0,0, SRCCOPY);
dcMem.SelectObject(pOldBmp);
In the OnInitialUpdate() set the sizeTotal variable to the desired size (600x600) and add following bit of code:
Code:
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = sizeTotal.cx;
bmi.bmiHeader.biHeight = -sizeTotal.cy; // top-down
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
m_bmp.Attach( CreateDIBSection( *GetDC(), &bmi, DIB_RGB_COLORS, (void**)&m_pdwBits, NULL, NULL) );
ZeroMemory(m_pdwBits, sizeof(sizeTotal.cx*sizeTotal.cy*sizeof(DWORD)));
You can then use the m_pdwBits variable as a simple bitmap. each "pixel" is a 32bit RGB pixel in ARGB format.
to set a pixel at 100x50 to purple.
m_pdwBits[ 100*600 + 50 ] = 0x00FF00FF; // set red and blue to 255.
be careful not to write outside of your given size.
With the above code, 0,0 of the bitmap will be located at the top left of the window, with increasing Y pointing downward
If you'd like it at the bottom left with increasing Y going upward. set biHeight to the poxitive value rather than the negative one.
When you have made changes to the bitmap and want to see them. Invalidate the window with Invalidate();