Created
July 6, 2011 21:21
-
-
Save taxilian/1068352 to your computer and use it in GitHub Desktop.
Example windows image draw function for FireBreath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void PluginObject::drawImage(FB::PluginWindow *wnd, FB::PluginEvent* evt, unsigned char *img, int width, int height) { | |
HDC hdc=NULL; | |
BITMAPINFO bitmapInfo; | |
bitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | |
bitmapInfo.bmiHeader.biBitCount=32; | |
bitmapInfo.bmiHeader.biCompression=BI_RGB; | |
bitmapInfo.bmiHeader.biPlanes = 1; | |
bitmapInfo.bmiHeader.biSizeImage = width*height*4; | |
bitmapInfo.bmiHeader.biWidth = width; | |
bitmapInfo.bmiHeader.biHeight = height; | |
FB::PluginWindowWin *winwin = dynamic_cast< FB::PluginWindowWin *>(wnd); | |
if(winwin!=NULL) { | |
PAINTSTRUCT ps; | |
hdc = BeginPaint(winwin->getHWND(), &ps); | |
if(hdc==NULL) return; | |
int dstWidth = wnd->getWindowWidth(); | |
int dstHeight = wnd->getWindowHeight(); | |
SetStretchBltMode(hdc, HALFTONE); | |
StretchDIBits(hdc, 0, dstHeight, dstWidth, -dstHeight, 0,0, width, height, img, &bitmapInfo,DIB_RGB_COLORS,SRCCOPY); | |
EndPaint(winwin->getHWND(), &ps); | |
} | |
FB::PluginWindowlessWin *windowlesswin = dynamic_cast< FB::PluginWindowlessWin *>(wnd); | |
if(windowlesswin!=NULL) { | |
hdc=windowlesswin->getHDC(); | |
FB::Rect r = wnd->getWindowPosition(); | |
int dstWidth = wnd->getWindowWidth(); | |
int dstHeight = wnd->getWindowHeight(); | |
SetStretchBltMode(hdc, HALFTONE); | |
StretchDIBits(hdc, r.left, r.bottom, dstWidth, -dstHeight, 0,0, width, height, img, &bitmapInfo,DIB_RGB_COLORS,SRCCOPY); | |
if(hdc==NULL) return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if npapi can wrap an activex transparent contrlol ?