Skip to content

Instantly share code, notes, and snippets.

@taxilian
Created July 6, 2011 21:21
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taxilian/1068352 to your computer and use it in GitHub Desktop.
Save taxilian/1068352 to your computer and use it in GitHub Desktop.
Example windows image draw function for FireBreath
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;
}
}
@stoneskill
Copy link

if npapi can wrap an activex transparent contrlol ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment