gdi

How to capture the screen with the “Tool Tips”?

邮差的信 提交于 2019-11-27 17:25:55
问题 I am using GDI to capture the screen, and I have noticed that the "Tool Tips" are not included in the screenshot. This is my basic code: HDC hdcDesk = GetDC(0); HDC hdcMem = CreateCompatibleDC(hdcDesk); HBITMAP hbmMem = CreateCompatibleBitmap(hdcDesk, 1920, 1080); SelectObject(hdcMem, hbmMem); StretchBlt(hdcMem, 0, 0, 1920, 1080, hdcDesk, 0, 0, 1920, 1080, SRCCOPY); // Now save the bitmap... Can this be fixed, or should I use another approach to capture the screen (other than GDI)? Edit: This

Transparency to text in GDI

ⅰ亾dé卋堺 提交于 2019-11-27 16:35:08
问题 i have created a Bitmap using GDI+.I am drawing text on to that bitmap using GDI Drawtext.Using Drawtext i am unable to apply tranparency. Any help or code will be appreciated. 回答1: If you want to draw text without a background fill, SetBkMode(hdc,TRANSPARENT) will tell GDI to leave the background when drawing text. To actually render the foreground color of the text with alpha... is going to be more complicated. GDI does not actually support alpha channels all that widely in its APIs.

C# Drawing on Panels

允我心安 提交于 2019-11-27 16:10:20
I'm drawing up a day schedule and representing timeslots with panels, and appointments are yet more panels on top. The user is able to scroll up and down so that the range they can see is shifted earlier or later. When an appointment runs off the end of the visible range, I want there to be a zig-zag indicating that the appointment extends beyond the visible bounds. I've identified the case where this occurs, and I call a private function drawZigZag(Panel p, int direction); to draw it. The day is spread horizontally, and the direction -1 indicates a zigzag on the left and 1 indicates a zigzag

GDI handle leak using TGIFImage in a second thread

时光总嘲笑我的痴心妄想 提交于 2019-11-27 13:15:04
问题 I have a background thread which loads images (either from disk or a server), with the goal of eventually passing them to the main thread to draw. When this second thread is loading GIF images using the VCL's TGIFImage class, this program sometimes leaks several handles each time the following line executes in the thread: m_poBitmap32->Assign(poGIFImage); That is, the just-opened GIF image is being assigned to a bitmap owned by the thread. None of these are shared with any other threads, i.e.

从零开始学习GDI+ (一)

老子叫甜甜 提交于 2019-11-27 12:22:47
前言: GDI+从Windows XP操作系统(大概2002-2003年)开始引入的,现在都9102年了,再学习这么古老的技术肯定是过时了。windows桌面程序没落了,随着移动的兴起,用户被惯坏了,现在,用户对界面的要求不只是可以用, 而且天生(自发、自然而然)的希望界面能够顺滑、流畅、微动画、抽屉效果、淡入淡出等等。使用GDI+去实现这些高端的界面需求是十分困难而工作量巨大的。因此,建议转前端学习html5,跨平台,效果又炫。如果硬要在windows 上开发,可以关注下NUI(natural user interface)。 那,我为什么仍然写这个博客呢。额,一言难尽,个人目前面临转型的困难。一直都在windows平台上开发与工作,去转个前端新手肯定不太乐意。而且,也没系统得学习过GDI+,觉得花一个月系统学习下还是值得的吧。人, 往往想的太多,做的太少。写这个系列也为了督促自己。如果对他人有益就更好了。 我接触GDI+是因为最近的两个需求,项目是基于网易云信Duilib开发的,一个是圆角矩形(GDI+抗锯齿比较好) https://www.cnblogs.com/xuhuajie/p/11281075.html 另外个是圆形进度条。 https://www.cnblogs.com/xuhuajie/p/11352714.html ok,废话不多说,开始学习吧。 GDI+

GDI+一般性错误(A generic error occurred in GDI+)

只谈情不闲聊 提交于 2019-11-27 12:20:15
//保存目录 string dir = "/upload/user/head"; //站点文件目录 string fileDir = HttpContext.Current.Server.MapPath("~" + dir); //文件名称 string fileName = "headdemo" + DateTime.Now.ToString("yyyyMMddHHmmssff"); //保存文件所在站点位置 string filePath = Path.Combine(fileDir, fileName); if (!System.IO.Directory.Exists(fileDir)) System.IO.Directory.CreateDirectory(fileDir); //读图片转为Base64String System.Drawing.Bitmap bmp1 = new System.Drawing.Bitmap(Path.Combine(fileDir, "default.jpg")); using (MemoryStream ms1 = new MemoryStream()) { bmp1.Save(ms1, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] arr1 = new byte[ms1.Length]

C# WinForms - Anyone know of a C# GDI library not SLOW GDI+

杀马特。学长 韩版系。学妹 提交于 2019-11-27 09:53:37
问题 GDI+ is very slow, almost entirely software whereas GDI is highly hardware accelerated. GDI+ is what the Graphics class uses on WinForms and it's just too slow. Has anyone made a .NET GDI library so we can have the speed? [EDIT] Many people are recommending OpenGL/DirectX. A requirement of mine is client compatibility especially remote desktop. AFAIK remote desktop does not support OGL/DirectX out of the box.[/EDIT] 回答1: Text rendering in GDI+ is slower than GDI. Microsoft realized this after

Is there a faster alternative to GDI GetPixel()?

本秂侑毒 提交于 2019-11-27 08:57:39
I'm using GetPixel() from gdi32.dll in a .NET app to sample the colour of a pixel anywhere on the screen. It works ok but it is a major performance bottleneck for me. Is there a faster way of doing it? Fast access to pixels are possible using LockBits() method of the Bitmap . This will return to you an object containing a pointer to the start of the pixel data and you can use unsafe code to access the memory. http://www.bobpowell.net/lockingbits.htm GetPixel is slow for two reasons: Since you're polling the screen - every call to GetPixel leads to a transaction to the video driver, which in

Creating HBITMAP from memory buffer

僤鯓⒐⒋嵵緔 提交于 2019-11-27 05:34:38
I have an application which loads some blob data out of a database which can represent png formatted or raw binary data for various bitmaps and icons. This is being stored in a std::vector<unsigned char> I'm using CImageList objects to display various images in tree views, toolbar images, etc but the problem is creating bitmaps from the data in memory are coming out fuzzy as if it's missing pixels when doing something like below: std::vector<unsigned char> bits; HBITMAP hbitmap = CreateBitmap(16, 16, 1, 32, bits.data()); To work around this issue for now I am simply writing out the data() in

Once and for all: how do I get a fully transparent checkbox, button, radio button, etc. in Windows API, and not with a black background?

核能气质少年 提交于 2019-11-27 04:56:03
问题 First, sorry if I sound arrogant/rude here. All right, so everyone has run into this by now (I hope); I just haven't found any adequate answer anywhere . We start with a Common Controls 6 manifest and case WM_CTLCOLORSTATIC: if (/* window has WS_EX_TRANSPARENT */) { SetBkMode((HDC) wParam, TRANSPARENT); return (LRESULT) GetStockObject(HOLLOW_BRUSH); } and give our labels WS_EX_TRANSPARENT . They become transparent; so far so good. Now we have to add that style to our checkboxes (because