I have a function generating an array that I need to draw to the screen. The array is in the form of an 8 bit grayscale image. How can I draw the array to the screen properly? I have a working version of this app in with win32 code which uses StretchDIBits to draw the image. My question is, can I/how can I do something similar in wxWidgets?
Relevant working win32 code:
screen = LCD_image( calcs[slot].cpu.pio.lcd ) ;
if (StretchDIBits( hdc,
rc.left, rc.top, rc.right - rc.left, 开发者_如何学JAVA rc.bottom - rc.top,
0, 0, lcd->width, 64,
screen,
bi,
DIB_RGB_COLORS,
SRCCOPY) == 0) {
printf("error in SetDIBitsToDevice\n");
}
if (BitBlt( hdcDest, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
hdc, 0, 0, SRCCOPY ) == FALSE) printf("Bit blt failed\n");
Relevant non-working wxWidgets code:
unsigned char *screen;
screen = LCD_image( calcs[gslot].cpu.pio.lcd ) ;
wxImage screenImage(rc.GetWidth(), rc.GetHeight(), screen, true);
wxBitmap bmpBuf(screenImage);
wxMemDC.SelectObject(bmpBuf);
wxDCDest->Blit(drawPoint.x, drawPoint.y, rc.GetWidth(), rc.GetHeight(), &wxMemDC, 0, 0);
wxMemDC.SelectObject(wxNullBitmap);
The format expected by wxImage ctor is an array of RGB data and your LCD_image()
function doesn't return it in this format.
精彩评论