开发者

wxWidgets display bitmap from an 8 bit array

开发者 https://www.devze.com 2023-01-15 04:23 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消