diff -r d4e164906a1b -r c6b5c552980a src/test.cpp --- a/src/test.cpp Thu May 22 21:32:45 2014 +0200 +++ b/src/test.cpp Thu May 22 22:36:43 2014 +0200 @@ -55,7 +55,8 @@ MainWindow::MainWindow(FXApp *app) : FXMainWindow(app, "HIDAPI Test Application", NULL, NULL, DECOR_ALL, 200,100, 600,900), iCurrentFont(NULL), - iFontImage(NULL) + iFontImage(NULL), + iPixelBuffer(NULL) { iBrightness=iVfd01.MaxBrightness(); devices = NULL; @@ -173,6 +174,9 @@ delete iFontImage; iFontImage = NULL; + delete[] iPixelBuffer; + iPixelBuffer = NULL; + if (connected_device) hid_close(connected_device); hid_exit(); @@ -754,9 +758,13 @@ delete iFontImage; iFontImage = NULL; // - FXString text="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-[]{}();%$£&~#|_"; + delete[] iPixelBuffer; + iPixelBuffer=NULL; + + //FXString text="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-[]{}();%$£&~#|_"; + FXString text="0123456789ABCDEF"; //Create an image the proper size for our text - iFontImage = new FXTGAImage(getApp(),NULL,IMAGE_SHMI|IMAGE_SHMP,iCurrentFont->getTextWidth(text),iCurrentFont->getFontHeight()); + iFontImage = new FXTGAImage(getApp(),NULL,IMAGE_KEEP/*IMAGE_SHMI|IMAGE_SHMP*/,iCurrentFont->getTextWidth(text),iCurrentFont->getFontHeight()); iFontImage->create(); //Perform our drawing { @@ -771,13 +779,39 @@ dc.drawText(0,iCurrentFont->getFontAscent(),text); //dc.end(); } + + //Save to file FXFileStream file; file.open("fonttest.tga",FXStreamSave); iFontImage->restore(); iFontImage->savePixels(file); file.close(); - // + //Create display pixel buffer from our image pixels + int w=iFontImage->getWidth(); + int h=iFontImage->getHeight(); + int pixelBufferSize=(w*h)/8; + iPixelBuffer = new unsigned char[pixelBufferSize]; + memset(iPixelBuffer,0x00,pixelBufferSize); + for (int i=0;igetPixel(i,j); + if (color!=0xffffffff) + { + iPixelBuffer[byteOffset] |= ( 1 << bitOffset ); + } + } + } + + if (iVfd01.IsOpen()) + { + iVfd01.SetPixelBlock(0,0,h-1,pixelBufferSize,iPixelBuffer); + iVfd01.SwapBuffers(); + } }