W32API.HBITMAP outputBitmap = GDI.CreateCompatibleBitmap(windowDC, bounds.width, bounds.height); try W32API.HDC blitDC = GDI.CreateCompatibleDC(windowDC); try W32API.HANDLE oldBitmap = GDI.SelectObject(blitDC, outputBitmap); try GDI.SelectObject(blitDC, oldBitmap); GDI.DeleteObject(blitDC); GDI.DeleteObject(outputBitmap);
try { if (memDC == null) { memDC = gdi.CreateCompatibleDC(screenDC); gdi.DeleteObject(hBitmap); hBitmap = null; bmi.bmiHeader.biSizeImage = ww * wh * 4; PointerByReference ppbits = new PointerByReference(); hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS, ppbits, null, 0); bitmapSize = new Dimension(ww, wh); oldBitmap = gdi.SelectObject(memDC, hBitmap); Raster raster = buf.getData(); int[] pixel = new int[4]; user.ReleaseDC(null, screenDC); if (memDC != null && oldBitmap != null) { gdi.SelectObject(memDC, oldBitmap);
hdcTargetMem = GDI32.INSTANCE.CreateCompatibleDC(hdcTarget); if (hdcTargetMem == null) { throw new Win32Exception(Native.getLastError()); hBitmap = GDI32.INSTANCE.CreateCompatibleBitmap(hdcTarget, windowWidth, windowHeight); if (hBitmap == null) { throw new Win32Exception(Native.getLastError()); hOriginal = GDI32.INSTANCE.SelectObject(hdcTargetMem, hBitmap); if (hOriginal == null) { throw new Win32Exception(Native.getLastError()); if (!GDI32.INSTANCE.BitBlt(hdcTargetMem, 0, 0, windowWidth, windowHeight, hdcTarget, 0, 0, GDI32.SRCCOPY)) { throw new Win32Exception(Native.getLastError()); int resultOfDrawing = GDI32.INSTANCE.GetDIBits(hdcTarget, hBitmap, 0, windowHeight, buffer, bmi, WinGDI.DIB_RGB_COLORS); if (resultOfDrawing == 0 || resultOfDrawing == WinError.ERROR_INVALID_PARAMETER) { HANDLE result = GDI32.INSTANCE.SelectObject(hdcTargetMem, hOriginal); if (!GDI32.INSTANCE.DeleteObject(hBitmap)) { Win32Exception ex = new Win32Exception(Native.getLastError()); if (we != null) { if (!GDI32.INSTANCE.DeleteDC(hdcTargetMem)) { Win32Exception ex = new Win32Exception(Native.getLastError()); if (we != null) {
static void drawHBITMAP(HBITMAP hbm, int x, int y, int cx, int cy, HDC hdcDst) { HDC hdcSrc = GDI32.INSTANCE.CreateCompatibleDC(hdcDst); HANDLE old = GDI32.INSTANCE.SelectObject(hdcSrc, hbm); BLENDFUNCTION.ByValue bld = new BLENDFUNCTION.ByValue(); bld.BlendOp = WinUser.AC_SRC_OVER; bld.BlendFlags = 0; bld.SourceConstantAlpha = (byte) 255; bld.AlphaFormat = WinUser.AC_SRC_ALPHA; if (!Msimg32.INSTANCE.AlphaBlend(hdcDst, x, y, cx, cy, hdcSrc, 0, 0, cx, cy, bld)) throw new GetLastErrorException(); GDI32.INSTANCE.SelectObject(hdcSrc, old); if (!GDI32.INSTANCE.DeleteDC(hdcSrc)) throw new GetLastErrorException(); }
int h = image.getHeight(null); HDC screenDC = user.GetDC(null); HDC memDC = gdi.CreateCompatibleDC(screenDC); HBITMAP hBitmap = null; hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS, ppbits, null, 0); Pointer pbits = ppbits.getValue(); } finally { user.ReleaseDC(null, screenDC); gdi.DeleteDC(memDC);
private void disposeBackingStore() { GDI32 gdi = GDI32.INSTANCE; if (hBitmap != null) { gdi.DeleteObject(hBitmap); hBitmap = null; } if (memDC != null) { gdi.DeleteDC(memDC); memDC = null; } } @Override
public void close() { if (hbm != null) { GDI32.INSTANCE.DeleteObject(hbm); hbm = null; } }
protected void setMask(final Component w, final Raster raster) { GDI32 gdi = GDI32.INSTANCE; final HRGN region = raster != null ? gdi.CreateRectRgn(0, 0, 0, 0) : null; if (region != null) { final HRGN tempRgn = gdi.CreateRectRgn(0, 0, 0, 0); try { RasterRangesUtils.outputOccupiedRanges(raster, new RasterRangesUtils.RangesOutput() { public boolean outputRange(int x, int y, int w, int h) { GDI32 gdi = GDI32.INSTANCE; gdi.SetRectRgn(tempRgn, x, y, x + w, y + h); return gdi.CombineRgn(region, region, tempRgn, WinGDI.RGN_OR) != WinGDI.ERROR; } }); } finally { gdi.DeleteObject(tempRgn); } } setWindowRegion(w, region); } }
if (iconInfo.hbmColor != null && iconInfo.hbmColor.getPointer() != Pointer.NULL) { final int nWrittenBytes = GDI32.INSTANCE.GetObject( iconInfo.hbmColor, bmp.size(), bmp.getPointer()); bmp.read(); } else if (iconInfo.hbmMask != null && iconInfo.hbmMask.getPointer() != Pointer.NULL) { final int nWrittenBytes = GDI32.INSTANCE.GetObject( iconInfo.hbmMask, bmp.size(), bmp.getPointer()); bmp.read(); if (iconInfo.hbmColor != null && iconInfo.hbmColor.getPointer() != Pointer.NULL) GDI32.INSTANCE.DeleteObject(iconInfo.hbmColor); if (iconInfo.hbmMask != null && iconInfo.hbmMask.getPointer() != Pointer.NULL) GDI32.INSTANCE.DeleteObject(iconInfo.hbmMask);
@Override public boolean outputRange(int x, int y, int w, int h) { GDI32 gdi = GDI32.INSTANCE; gdi.SetRectRgn(tempRgn, x, y, x + w, y + h); return gdi.CombineRgn(region, region, tempRgn, WinGDI.RGN_OR) != WinGDI.ERROR; } });
SIZE measureItem(HWND hWnd, MenuMap mm) { HDC hdc = User32.INSTANCE.GetDC(hWnd); HANDLE hfntOld = (HANDLE) GDI32.INSTANCE.SelectObject(hdc, createSystemMenuFont()); SIZE size = new SIZE(); if (!GDI32Ex.INSTANCE.GetTextExtentPoint32(hdc, mm.item.getText(), mm.item.getText().length(), size)) throw new GetLastErrorException(); GDI32.INSTANCE.SelectObject(hdc, hfntOld); User32.INSTANCE.ReleaseDC(hWnd, hdc); size.cx += (getSystemMenuImageSize() + SPACE_ICONS) * 2; return size; }
counts[i] = sizes.get(i).intValue(); HRGN hrgn = gdi.CreatePolyPolygonRgn(lppt, counts, counts.length, mode); setWindowRegion(w, hrgn);
try { if (memDC == null) { memDC = gdi.CreateCompatibleDC(screenDC); gdi.DeleteObject(hBitmap); hBitmap = null; bmi.bmiHeader.biSizeImage = ww * wh * 4; PointerByReference ppbits = new PointerByReference(); hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS, ppbits, null, 0); bitmapSize = new Dimension(ww, wh); oldBitmap = gdi.SelectObject(memDC, hBitmap); Raster raster = buf.getData(); int[] pixel = new int[4]; user.ReleaseDC(null, screenDC); if (memDC != null && oldBitmap != null) { gdi.SelectObject(memDC, oldBitmap);
private void disposeBackingStore() { GDI32 gdi = GDI32.INSTANCE; if (hBitmap != null) { gdi.DeleteObject(hBitmap); hBitmap = null; } if (memDC != null) { gdi.DeleteDC(memDC); memDC = null; } } public void removeNotify() {
public void run() { GDI32 gdi = GDI32.INSTANCE; User32 user = User32.INSTANCE; HWND hWnd = getHWnd(w); try { user.SetWindowRgn(hWnd, hrgn, true); setForceHeavyweightPopups(getWindow(w), hrgn != null); } finally { gdi.DeleteObject(hrgn); } } });
@Override protected void setMask(final Component w, final Raster raster) { GDI32 gdi = GDI32.INSTANCE; final HRGN region = raster != null ? gdi.CreateRectRgn(0, 0, 0, 0) : null; if (region != null) { final HRGN tempRgn = gdi.CreateRectRgn(0, 0, 0, 0); try { RasterRangesUtils.outputOccupiedRanges(raster, new RasterRangesUtils.RangesOutput() { @Override public boolean outputRange(int x, int y, int w, int h) { GDI32 gdi = GDI32.INSTANCE; gdi.SetRectRgn(tempRgn, x, y, x + w, y + h); return gdi.CombineRgn(region, region, tempRgn, WinGDI.RGN_OR) != WinGDI.ERROR; } }); } finally { gdi.DeleteObject(tempRgn); } } setWindowRegion(w, region); }
public boolean outputRange(int x, int y, int w, int h) { GDI32 gdi = GDI32.INSTANCE; gdi.SetRectRgn(tempRgn, x, y, x + w, y + h); return gdi.CombineRgn(region, region, tempRgn, WinGDI.RGN_OR) != WinGDI.ERROR; } });
GDI32.INSTANCE.SelectObject(hDC, createSystemMenuFont()); GDI32Ex.INSTANCE.ExtTextOut(hDC, x, y, GDI32Ex.ETO_OPAQUE, rcItem, mm.item.getText(), mm.item.getText().length(), null);
counts[i] = sizes.get(i).intValue(); HRGN hrgn = gdi.CreatePolyPolygonRgn(lppt, counts, counts.length, mode); setWindowRegion(w, hrgn);
W32API.HDC windowDC = GDI.GetDC(USER.GetDesktopWindow()); W32API.HBITMAP outputBitmap = GDI.CreateCompatibleBitmap(windowDC, bounds.width, bounds.height); try { W32API.HDC blitDC = GDI.CreateCompatibleDC(windowDC); try { W32API.HANDLE oldBitmap = GDI.SelectObject(blitDC, outputBitmap); try { GDI.BitBlt(blitDC, GDI32.SRCCOPY); } finally { GDI.SelectObject(blitDC, oldBitmap); GDI.DeleteObject(blitDC); GDI.DeleteObject(outputBitmap);