void ws_destroy_font(FontObj f, DisplayObj d) { WsFont wsf = (WsFont) getExistingXrefObject(f, d); DEBUG(NAME_font, Cprintf("ws_destroy_font(%s)\n", pp(f))); if ( wsf ) { if ( !wsf->from_stock ) ZDeleteObject(wsf->hfont); unregisterXrefObject(f, d); } }
Image ws_grab_image_display(DisplayObj d, int x, int y, int width, int height) { HDC hdc = GetDC(NULL); RECT rect; Image image; int w, h; HBITMAP obm, bm; HDC hdcimg; Size size = getSizeDisplay(d); rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; if ( rect.left < 0 ) rect.left = 0; if ( rect.top < 0 ) rect.top = 0; if ( rect.bottom > valInt(size->h) ) rect.bottom = valInt(size->h); if ( rect.right > valInt(size->w) ) rect.right = valInt(size->w); w = rect.right - rect.left; h = rect.bottom - rect.top; image = answerObject(ClassImage, NIL, toInt(w), toInt(h), NAME_pixmap, EAV); assign(image, display, d); bm = ZCreateCompatibleBitmap(hdc, w, h); hdcimg = CreateCompatibleDC(hdc); obm = SelectObject(hdcimg, bm); BitBlt(hdcimg, 0, 0, w, h, hdc, rect.left, rect.top, SRCCOPY); SelectObject(hdcimg, obm); ZDeleteObject(hdcimg); ReleaseDC(NULL, hdc); registerXrefObject(image, image->display, (void *) bm); return image; }