Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Jul 15, 2017

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
You can’t perform that action at this time.