import com.sun.jna.platform.win32.WinDef.HDC; //導入依賴的package包/類/** * Gets the icon that corresponds to a given icon handler. * * @param hIcon * Handler to the icon to get * @return The icon that corresponds to a given icon handler */public static BufferedImage getIcon(final HICON hIcon) {final int width = ICON_SIZE;final int height = ICON_SIZE;final short depth = ICON_DEPTH;final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);final Memory lpBitsColor = new Memory(width * height * depth / ICON_BYTE_SIZE);final Memory lpBitsMask = new Memory(width * height * depth / ICON_BYTE_SIZE);final BITMAPINFO info = new BITMAPINFO();final BITMAPINFOHEADER hdr = new BITMAPINFOHEADER();info.bmiHeader = hdr;hdr.biWidth = width;hdr.biHeight = height;hdr.biPlanes = 1;hdr.biBitCount = depth;hdr.biCompression = WinGDI.BI_RGB;final HDC hDC = User32.INSTANCE.GetDC(null);final ICONINFO piconinfo = new ICONINFO();User32.INSTANCE.GetIconInfo(hIcon, piconinfo);GDI32.INSTANCE.GetDIBits(hDC, piconinfo.hbmColor, 0, height, lpBitsColor, info, WinGDI.DIB_RGB_COLORS);GDI32.INSTANCE.GetDIBits(hDC, piconinfo.hbmMask, 0, height, lpBitsMask, info, WinGDI.DIB_RGB_COLORS);int r, g, b, a, argb;int x = 0, y = height - 1;for (int i = 0; i < lpBitsColor.size(); i = i + 3) {b = lpBitsColor.getByte(i) & 0xFF;g = lpBitsColor.getByte(i + 1) & 0xFF;r = lpBitsColor.getByte(i + 2) & 0xFF;a = 0xFF - lpBitsMask.getByte(i) & 0xFF;argb = a << 24 | r << 16 | g << 8 | b;image.setRGB(x, y, argb);x = (x + 1) % width;if (x == 0) {y--;}}User32.INSTANCE.ReleaseDC(null, hDC);GDI32.INSTANCE.DeleteObject(piconinfo.hbmColor);GDI32.INSTANCE.DeleteObject(piconinfo.hbmMask);return image;}
import com.sun.jna.platform.win32.WinDef.HDC; //導入依賴的package包/類public BufferedImage capture(final HWND hWnd) { final HDC hdcWindow = User32.INSTANCE.GetDC(hWnd); final HDC hdcMemDC = GDI32.INSTANCE.CreateCompatibleDC(hdcWindow); final RECT bounds = new RECT(); User32Extra.INSTANCE.GetClientRect(hWnd, bounds); final int width = bounds.right - bounds.left; final int height = bounds.bottom - bounds.top; if (width * height <= 0) { return null; } final HBITMAP hBitmap = GDI32.INSTANCE.CreateCompatibleBitmap(hdcWindow, width, height); final HANDLE hOld = GDI32.INSTANCE.SelectObject(hdcMemDC, hBitmap); GDI32Extra.INSTANCE.BitBlt(hdcMemDC, 0, 0, width, height, hdcWindow, 0, 0, WinGDIExtra.SRCCOPY); GDI32.INSTANCE.SelectObject(hdcMemDC, hOld); GDI32.INSTANCE.DeleteDC(hdcMemDC); final BITMAPINFO bmi = new BITMAPINFO(); bmi.bmiHeader.biWidth = width; bmi.bmiHeader.biHeight = -height; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = WinGDI.BI_RGB; final Memory buffer = new Memory(width * height * 4); GDI32.INSTANCE.GetDIBits(hdcWindow, hBitmap, 0, height, buffer, bmi, WinGDI.DIB_RGB_COLORS); final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); image.setRGB(0, 0, width, height, buffer.getIntArray(0, width * height), 0, width); GDI32.INSTANCE.DeleteObject(hBitmap); User32.INSTANCE.ReleaseDC(hWnd, hdcWindow); return image; }
import com.sun.jna.platform.win32.WinDef.HDC; //導入依賴的package包/類/** * @param args (ignored) */public static void main(String[] args){System.out.println("Installed Physical Monitors: " + User32.INSTANCE.GetSystemMetrics(WinUser.SM_CMONITORS));User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {@Overridepublic int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam){enumerate(hMonitor);return 1;}}, new LPARAM(0));}
import com.sun.jna.platform.win32.WinDef.HDC; //導入依賴的package包/類public static BufferedImage getScreenshot( final Rectangle bounds ) {HDC windowDC = GDI.GetDC( USER.GetDesktopWindow() );HBITMAP outputBitmap = GDI.CreateCompatibleBitmap( windowDC, bounds.width, bounds.height );try {HDC blitDC = GDI.CreateCompatibleDC( windowDC );try {HANDLE oldBitmap = GDI.SelectObject( blitDC, outputBitmap );try {GDI.BitBlt( blitDC, 0, 0, bounds.width, bounds.height, windowDC, bounds.x, bounds.y, GDI32.SRCCOPY );} finally {GDI.SelectObject( blitDC, oldBitmap );}BITMAPINFO bi = new BITMAPINFO( 40 );bi.bmiHeader.biSize = 40;boolean ok = GDI.GetDIBits( blitDC, outputBitmap, 0, bounds.height, (byte[]) null, bi, WinGDI.DIB_RGB_COLORS );if ( ok ) {BITMAPINFOHEADER bih = bi.bmiHeader;bih.biHeight = -Math.abs( bih.biHeight );bi.bmiHeader.biCompression = 0;return bufferedImageFromBitmap( blitDC, outputBitmap, bi );} elsereturn null;} finally {GDI.DeleteObject( blitDC );}} finally {GDI.DeleteObject( outputBitmap );}}
本文由 貴州做網站公司 整理發布,部分圖文來源于互聯網,如有侵權,請聯系我們刪除,謝謝!
網絡推廣與網站優化公司(網絡優化與推廣專家)作為數字營銷領域的核心服務提供方,其價值在于通過技術手段與策略規劃幫助企業提升線上曝光度、用戶轉化率及品牌影響力。這...
在當今數字化時代,公司網站已成為企業展示形象、傳遞信息和開展業務的重要平臺。然而,對于許多公司來說,網站建設的價格是一個關鍵考量因素。本文將圍繞“公司網站建設價...
在當今的數字化時代,企業網站已成為企業展示形象、吸引客戶和開展業務的重要平臺。然而,對于許多中小企業來說,高昂的網站建設費用可能會成為其發展的瓶頸。幸運的是,隨...
回別人微信,回個“嗯”是什么意思?好吧,嘿,哇,哇,在《新華字典》8500個詞中,除了這些詞之外,還有近百個詞,至少百分之一?!癕MM”是兩個或更多人之間的對話。聲音不大,有鼻音。換句話說,它從鼻子發出聲音。你可以馬上試試。100%正確。我沒打擾你。好的,好的,好的,好的,好的,同意,書面同意,回文對聯很少用在臺詞中,但它們都用在對話中“,”…是的?!盀榱舜_定與否,我在聽你說。我心不在焉。我回復對...
移動Sim大卡換小卡?機主本人攜帶身份證,到任意一家移動營業廳,說可以辦理換卡業務。營業廳會根據您的需求更換大小合適的手機卡。以前手機卡是大卡,后來換成了minisim卡,就是老人機用的那種。隨著技術要求和變化,現在是micro sim卡,大部分手機都可以插。我的卡是外地的,可以去當地移動營業廳換小卡或者剪卡嗎?你可以 不要換一張小卡片。如果你的卡是大卡,你只能去手機店換,讓它給你剪成小卡。想換小...
百威9000v6商業管理軟件使用方法?百威?解壓下載的bw9000ziu.zip地址百威9000商務管理軟件的安裝程序見bw9000ziu程序安裝目錄安裝程序.exe下一步,選擇后臺管理和前臺出納,然后選擇下一步,在“輸入服務器名稱或IP地址”列中輸入測試服務器的域名“windowsce.vicp.net,如下一步:根據向導,繼續下一步,完成軟件安裝后,前臺出納測試可運行桌面“百威9000商用PO...