bitblt

BitBlt code not working

谁都会走 提交于 2019-11-30 14:19:20
问题 I'm trying to use this code to draw a Bitmap directly onto a PictureBox : Bitmap bmp = (Bitmap)Bitmap.FromFile(@"C:\Users\Ken\Desktop\Load2.bmp"); Graphics grDest = Graphics.FromHwnd(pictureBox1.Handle); Graphics grSrc = Graphics.FromImage(bmp); IntPtr hdcDest = grDest.GetHdc(); IntPtr hdcSrc = grSrc.GetHdc(); BitBlt(hdcDest, 0, 0, pictureBox1.Width, pictureBox1.Height, hdcSrc, 0, 0, (uint)TernaryRasterOperations.SRCCOPY); // 0x00CC0020 grDest.ReleaseHdc(hdcDest); grSrc.ReleaseHdc(hdcSrc);

BitBlt code not working

霸气de小男生 提交于 2019-11-30 10:16:53
I'm trying to use this code to draw a Bitmap directly onto a PictureBox : Bitmap bmp = (Bitmap)Bitmap.FromFile(@"C:\Users\Ken\Desktop\Load2.bmp"); Graphics grDest = Graphics.FromHwnd(pictureBox1.Handle); Graphics grSrc = Graphics.FromImage(bmp); IntPtr hdcDest = grDest.GetHdc(); IntPtr hdcSrc = grSrc.GetHdc(); BitBlt(hdcDest, 0, 0, pictureBox1.Width, pictureBox1.Height, hdcSrc, 0, 0, (uint)TernaryRasterOperations.SRCCOPY); // 0x00CC0020 grDest.ReleaseHdc(hdcDest); grSrc.ReleaseHdc(hdcSrc); but instead of rendering the Bitmap 's contents it just draws a solid block of nearly-black. I'm pretty

How to increase performance over GDI's DrawImage(Unscaled)?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 05:25:53
问题 In my user control's paint handler I iterate over a collection of predefined Bitmap objects and draw them to the client area thusly: C# version: private void Control_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; foreach (BitmapObj bmpObj in _bitmapObjCollection) { g.DrawImageUnscaled(bmpObj.Bitmap, bmpObj.Location); } } VB.NET version: Private Sub Control_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint Dim g As Graphics = e.Graphics For Each

PrintWindow and BitBlt of hidden windows

孤街浪徒 提交于 2019-11-28 04:45:07
问题 My program is taking screenshots of other application windows to automate some tasks on them. Those windows can be hidden offscreen or obscured by other windows from time to time. To reduce clutter, I have removed any error checking from the code listings. I am preparing the both types of screenshots with // Get size of the target window. RECT clientRect; GetClientRect(hwnd, &clientRect); int width = clientRect.right - clientRect.left; int height = clientRect.bottom - clientRect.top; //

BitBlt performance with Aero enabled

南楼画角 提交于 2019-11-27 15:18:24
问题 I'd like to get more performance out of BitBlt for capturing the screen. When Aero remains enabled, capturing only a 400x400 pixel area of the screen reduces capture time from an average of 50ms (full 1920x1200) to about 33ms (for 400x400) on my machine. This is a disappointingly low improvement. Is my only option disabling Aero? I do know that i can get a blinding fast 3ms capture on the full screen when Aero is disabled. 回答1: A screen capture in Aero mode is very expensive because it

Get Pixel color fastest way?

早过忘川 提交于 2019-11-27 01:11:42
问题 I'm trying to make an auto-cliker for an windows app. It works well, but it's incredibly slow! I'm currently using the method "getPixel" which reloads an array everytime it's called. Here is my current code: hdc = GetDC(HWND_DESKTOP); bx = GetSystemMetrics(SM_CXSCREEN); by = GetSystemMetrics(SM_CYSCREEN); start_bx = (bx/2) - (MAX_WIDTH/2); start_by = (by/2) - (MAX_HEIGHT/2); end_bx = (bx/2) + (MAX_WIDTH/2); end_by = (by/2) + (MAX_HEIGHT/2); for(y=start_by; y<end_by; y+=10) { for(x=start_bx; x