Alright... I got the alignment down, but came up with this messed up problem that I can't trace down. I resaved the file as I loaded it to make sure I am properly loading the file, and when I view the resaved file it looks exactly as the original so I know I am loading it correctly. Here's what's happening, at some width, that doesn't change, the image drops off, then after that same width the image comes back and it repeats in this manner. There's a couple pictures to show what I am talking about. As you can see the static window in grey has the correct width/height so I know it is not a problem with that. Also, the code below is how I am loading the bitmap, and how it is being displayed to the screen.
Code:
//After doing the header/info reading...
width = infoheader.biWidth; //assign width value
height = infoheader.biHeight; //assign height value
(*pixelmap) = (unsigned char*)malloc(width*height*3);
//ZeroMemory(*pixelmap, width*height*3);
unsigned char padding;
for (int i = 0; i < infoheader.biWidth*infoheader.biHeight; i++)
{
fread(&rgbt, sizeof(RGBTRIPLE), 1, l_file);
(*pixelmap)[j+0] = rgbt.rgbtRed; // Red component
(*pixelmap)[j+1] = rgbt.rgbtGreen; // Green component
(*pixelmap)[j+2] = rgbt.rgbtBlue; // Blue component
j += 3; // Go to the next position
if(i % infoheader.biWidth == 0){
for(int n = 0; n < infoheader.biWidth % 4; n++)
fread(&padding, 1, 1, l_file);
}
}
fclose(l_file); //closes the file stream
//Drawing proceedure, now it's not in WM_PAINT
//All the 'error' calls return ERR_SUCCESS, so it's not hitting out of bounds
case WM_DRAWCANVAS:
{
if(UpdateCanvasImage){
printf("UpdateCanvasImage = true\n");
UINT error;
///set up for displaying picture to the screen
InvalidateRect(hCanvas, 0, true);
PAINTSTRUCT ps;
HDC winDC = BeginPaint(hCanvas, &ps);
for(int y = 0; y < g_Canvas.Height(); y++){
for(int x = 0; x < g_Canvas.Width(); x++){
BYTE R = g_Canvas.GetPixel(x, y, PIXEL_R, error);
if(error != ERR_SUCCESS) cout<< error <<endl;
BYTE G = g_Canvas.GetPixel(x, y, PIXEL_G, error);
if(error != ERR_SUCCESS) cout<< error <<endl;
BYTE B = g_Canvas.GetPixel(x, y, PIXEL_B, error);
if(error != ERR_SUCCESS) cout<< error <<endl;
SetPixel(winDC, x, lParam - y, RGB(R, G, B));
}
}
EndPaint(hCanvas, &ps);
///End set up for displaying picture to screen
PostMessage(hwnd, RECEIVE_MSG, MSG_SETREADY, 0);
UpdateCanvasImage = false;
}
}
break;
EDIT: sorry for the size, I don't know how to make the images stacked.