gdi

C++/Win32: How to get the alpha channel from an HBITMAP?

人走茶凉 提交于 2019-11-30 19:06:23
I have an HBITMAP containing alpha channel data. I can successfully render this using the ::AlphaBlend GDI function. However, when I call the ::GetPixel GDI function, I never get back values with an alpha component. The documentation does say that it returns the RGB value of the pixel. Is there a way to retrieve the alpha channel values for pixels in an HBITMAP ? I want to be able to detect when to use ::AlphaBlend, and when to use an old-school method for treating a particular colour in the source HBITMAP as transparent. HDC sourceHdc = ::CreateCompatibleDC(hdcDraw); ::SelectObject(sourceHdc,

How to rotate Bitmap in windows GDI?

爱⌒轻易说出口 提交于 2019-11-30 18:36:30
How would I go about rotating a Bitmap in Windows GDI,C++? You can do it with GDI+ ( #include <gdiplus.h> ). The Graphics class has the RotateTransform method . That allows arbitrary rotations. Use Image::RotateFlip() if you only need to rotate by 90 degree increments, that's a lot more efficient. Sounds like you have to use PlgBlt . Take your rectangle's 4 corners as 2D Points, rotate them, then call PlgBlt. From MSDN Bitmap Rotation : To copy a bitmap into a parallelogram; use the PlgBlt function, which performs a bit-block transfer from a rectangle in a source device context into a

WPF: Use font installed with 'AddFontMemResourceEx' for process only

烈酒焚心 提交于 2019-11-30 18:29:11
问题 In WPF we would like to use ttf fonts as embedded resources without copying or installing these to the system and without actually writing these to disk. Without memory leak issues. None of the solutions detailed in: How to include external font in WPF application without installing it are useable in this scenario due to the WPF memory leak around this: WPF TextBlock memory leak when using Font Installing fonts from memory and process only is possible in GDI via AddFontMemResourceEx . Since

How to generate a monochrome bit mask for a 32bit bitmap

那年仲夏 提交于 2019-11-30 14:12:30
问题 Under Win32, it is a common technique to generate a monochrome bitmask from a bitmap for transparency use by doing the following: SetBkColor(hdcSource, clrTransparency); VERIFY(BitBlt(hdcMask, 0, 0, bm.bmWidth, bm.bmHeight, hdcSource, 0, 0, SRCCOPY)); This assumes that hdcSource is a memory DC holding the source image, and hdcMask is a memory DC holding a monochrome bitmap of the same size (so both are 32x32, but the source is 4 bit color, while the target is 1bit monochrome). However, this

Invert Text Color depending on BackColor

你说的曾经没有我的故事 提交于 2019-11-30 13:43:39
I have a ProgressBar control like the following two: The first is painted properly. As you can see, the second only has one 0, it's supposed to have two but the other cannot be seen because ProgressBar's ForeColor is the same as the TextColor . Is there a way I can paint the text in black when the ProgressBar below is painted in Lime and paint the text in Lime when the background is black? You can first draw the background and text, then draw the foreground lime rectangle using PatBlt method with PATINVERT parameter to combine foreground drawing with background drawing: using System; using

Android核心分析28篇,强烈推荐android初学者,android进阶者看看这个系列教程

偶尔善良 提交于 2019-11-30 10:33:36
文章链接:http://www.apkbus.com/android-24246-1-1.html 为什么要研究Android,是因为它够庞大,它够复杂,他激起了我作为一个程序员的内心的渴望,渴望理解这种复杂性。我研究的对象是作为手机开发平台的Android软件系统部分,而不是Dalvik虚拟机本身。   作为一个从其他平台装接过来的程序员,要从事Andoid平台系统开发,我的关于手机平台上积累的知识已经不能满足需要了,Android为我们带来了大量的新名词,Activity,Manifest,INTENT,Service,Binder,Dalvik虚拟机,Framework,Linux,Navtive ,JNI.....。通过在源代码,在开发社区,在开发博客,甚至在招聘过程中,我不断的寻求Android是什么。经过一定时间的沉淀,我慢慢的理解到Android不仅仅是一类手机的总称,不仅仅是一个手机开发平台,不仅仅是一个虚拟java操作系统,不仅仅是一个开发社区,一个开发标准,不仅仅是一堆代码,Android已经成了一个新的潮流。 Android核心分析28篇 http://www.apkbus.com/android-24246-1-1.html Android核心分析 之一分析方法论探讨之设计意图 http://www.apkbus.com/android-24212-1-1

Draw all the Non-Client area in C#

ⅰ亾dé卋堺 提交于 2019-11-30 09:47:08
问题 I am looking to draw my non-client area in C#, for example, instead a rectangle as a form, i want an ellipse (this is an example), but how can i do it? I basically want to draw all my non client area, and i think to do that i will have to override some methods, but which ones? I have found an example that uses 'xaml', what i think that is windows presentation foundation app, but i haven't understand it well. 回答1: m0sa has provided a WPF answer already. For WinForms, you'll need to process the

How to generate a monochrome bit mask for a 32bit bitmap

孤街醉人 提交于 2019-11-30 09:17:17
Under Win32, it is a common technique to generate a monochrome bitmask from a bitmap for transparency use by doing the following: SetBkColor(hdcSource, clrTransparency); VERIFY(BitBlt(hdcMask, 0, 0, bm.bmWidth, bm.bmHeight, hdcSource, 0, 0, SRCCOPY)); This assumes that hdcSource is a memory DC holding the source image, and hdcMask is a memory DC holding a monochrome bitmap of the same size (so both are 32x32, but the source is 4 bit color, while the target is 1bit monochrome). However, this seems to fail for me when the source is 32 bit color + alpha. Instead of getting a monochrome bitmap in

Generating PDF files from .NET by using standard .NET GDI printing classes

梦想与她 提交于 2019-11-30 07:38:00
I'm looking for a way to generate PDF files using the standard PrintDocument and Graphics (GDI) classes in .NET. As far as I know, the only way to do that is by printing to a PDF printer. The problem is that a PDF printer driver always asks for a filename, but I need to control the filename from my code. Using a PDF library like PDFSharp or DynamicPDF is not an option, because they all provide their own API for generating PDF files. I need this for an internal application, so dependencies are not a problem. My question is simple: is there a way to control a printer driver (Adobe Acrobat,

how do I do print preview in win32 c++?

蓝咒 提交于 2019-11-30 06:59:22
问题 I have a drawing function that just takes an HDC. But I need to show an EXACT scaled version of what will print. So currently, I use CreateCompatibleDC() with a printer HDC and CreateCompatibleBitmap() with the printer's HDC. I figure this way the DC will have the printer's exact width and height. And when I select fonts into this HDC, the text will be scaled exactly as the printer would. Unfortunately, I can't to a StretchBlt() to copy this HDC's pixels to the control's HDC since they're of