gdi

Equality of GDI+ Regions

心不动则不痛 提交于 2020-02-04 20:43:50
问题 Why does the assertion fail in the following code? Why aren't regions a and b equal? Region a = new Region(new RectangleF(0.0f, 0.0f, 10.0f, 10.0f)); Region b = new Region(); b.MakeEmpty(); b.Union(new RectangleF(0.0f, 0.0f, 10.0f, 10.0f)); Debug.Assert(a == b, "Regions not equal"); 回答1: From what I can see, System.Drawing.Region does not override Object 's implementation of Equals() . Therefore your == call is using ReferenceEquals and simply telling you a and b are not the same object. Try

利用 GDI+ 绘制旋转的太极

冷暖自知 提交于 2020-02-02 17:54:57
1 // TaiJi.cpp : 定义应用程序的入口点。 2 // 3 4 #include " stdafx.h " 5 #include " TaiJi.h " 6 7 /* 8 * 由于需要用GDI+进行绘图,所以需要先含GDI+库 9 * 首先,包含Gdiplus.h头文件, 引入Gdiplus命名空间, 包含gdiplus.lib库 10 * 在stdafx.h头文件中,取消 WIN32_LEAN_AND_MEAN 宏的定义,如果不取消这个宏定义,编译时会报错. 11 */ 12 #include <GdiPlus.h> 13 using namespace Gdiplus; 14 #pragma comment(lib, "gdiplus.lib") 15 16 #define MAX_LOADSTRING 100 17 18 // 全局变量: 19 HINSTANCE hInst; // 当前实例 20 TCHAR szTitle[MAX_LOADSTRING] = TEXT( " 旋转的太极 " ); // 标题栏文本 21 TCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名 22 23 ULONG_PTR GdiplusToken; 24 25 // 此代码模块中包含的函数的前向声明: 26 ATOM

Delphi GDI 图形设备接口Graphics Device Interface

耗尽温柔 提交于 2020-02-01 22:24:22
GDI (图形设备接口(Graphics Device Interface)) GDI是图形设备接口的英文缩写,主要任务是负责系统与绘图程序之间的信息交换,处理所有Windows程序的图形和图像输出。GDI的出现使程序员无需要关心硬件设备及设备正常驱动,就可以将应用程序的输出转化为硬件设备上的输出和构成,实现了程序开发者与硬件设备的隔离,大大方便了开发工作。 在Windows操作系统下,绝大多数具备图形界面的应用程序都离不开GDI,我们利用GDI所提供的众多函数就可以方便的在屏幕、打印机及其它输出设备上输出图形,文本等操作。 特点: 1. 不允许程序直接访问物理显示硬件,通过称为“设备环境”的抽象接口间接访问显示硬件; 2. 程序需要与显示硬件(显示器、打印机等) 进行通讯时,必须首先获得与特定窗口相关联的设备环境; 3. 用户无需关心具体的物理设备类型; 4. Windows参考设备环境的数据结构完成数据的输出。 GDI函数大致可分类为: 设备上下文函数(如GetDC、CreateDC、DeleteDC)、 画线函数(如LineTo、Polyline、Arc)、 填充画图函数(如Ellipse、FillRect、Pie)、 画图属性函数(如SetBkColor、SetBkMode、SetTextColor)、 文本、字体函数(如TextOut、GetFontData)、 位图函数

How to effectively draw on desktop in C#?

前提是你 提交于 2020-01-26 11:35:31
问题 I want to draw directly on the desktop in C#. From searching a bit, I ended up using a Graphics object from the Desktop HDC (null). Then, I painted normally using this Graphics object. The problem is that my shapes get lost when any part of the screen is redrawn. I tried a While loop, but it actually ends up drawing as fast as the application can, which is not the update rate of the desktop. Normally, I would need to put my drawing code in a "OnPaint" event, but such thing does not exist for

Paint invalid areas of a window using Win32 API and GDI

强颜欢笑 提交于 2020-01-25 21:14:52
问题 First, I'm new here, so hello world! I'm working on a little lightweight controls library. Each control is an instance of a class named "GraphicElement", and doesn't have a handle. I created an event dispatcher and it works as expected but I struggle with the painting of my controls. They are stored in a tree, and I paint them as I go through this tree. I also use a back buffer to ensure the window's content doesn't flicker. Everything works fine, but when I move one of the controls, this

Confused between logical coordinates and device coordinates in Windows API

感情迁移 提交于 2020-01-23 05:41:07
问题 I have been looking into a Visual Studio C++ Windows application project which used two functions SetWindowExt (...) and SetViewportExt (...) . I am confused about what these two functions do and why they are necessary. Searching about these functions, I came to the concept of logical coordinates and device coordinates. Can anyone please explain what is the importance of these two concepts? 回答1: Device coordinates are the simplest to understand. They are directly related to the device that

【笨嘴拙舌WINDOWS】GDI(1)

坚强是说给别人听的谎言 提交于 2020-01-17 07:58:54
GDI:Graphics Device Interface 图形设备接口。 操作系统从命令行界面到图形界面的过度是施乐公司实验室对计算机普及作出的不可估量的贡献,苹果公司乔布斯与微软公司比尔盖茨对其的推广更是举世瞩目。作为该项技术的发明者并没有收获到自己的面包!由此可见: 创新并不一定能够在使公司在商场上立于不败之地! 苹果公司从硬件到软件,到销售一体化的服务如今也是取得了万人膜拜的成就,可是在当年失败的恰好是他的封闭。微软公司利用苹果的封闭,与硬件生产商联合起来推出低价的PC,自己专心做软件,一步步将WINDOWS推向浪潮之巅!可如今的微软依旧和硬件生产商合作却不能撬开移动领域的大门!由此可见: 不同的时代,不同的人,做产品需要不同的方法!改变才能跟进时代! 为了支持各个硬件厂商的显示器设备(打印机同理),WINDOWS需要在显示器驱动接口的上多一层封装,这样就产生了GDI。 软件开发中遇到的所有问题,都可以通过增加一层抽象而得以解决。 现在的显示器多为点阵结构,只是发光原理不同!即可以想象成一个显示器,由若干个整齐排列灯泡组成,等亮就发光! “此为分辨率为8X8的显示器” 以下我将接受GDI函数: 1.SetPixel(dc,1,1,RED) 2.Lineto(dc,8,1) “LineTo并不包括终点” 3.Rectangle(dc,1,1,5,4) RoundRect(dc

Accordance between pixel and mm

无人久伴 提交于 2020-01-17 07:41:11
问题 I'm doing: PhysicalParameters() { IntPtr DeskTopHWND = GetDesktopWindow(); IntPtr HDC = GetDC(DeskTopHWND); int mmX = GetDeviceCaps(HDC, HORZSIZE); int mmY = GetDeviceCaps(HDC, VERTSIZE); int pxX = GetDeviceCaps(HDC, HORZRES); int pxY = GetDeviceCaps(HDC, VERTRES); ReleaseDC(DeskTopHWND, HDC); double CoeffPIX_MM_X = 1.0 * mmX / pxX; double CoeffPIX_MM_Y = 1.0 * mmY / pxY; } The result for both is 0.25 But what I see (MS Word' WysiWyg ) it should be about 0.27 Please, explain the subject. 回答1:

How do you do both blending and transparency using just pure VCL on bitmapped images?

做~自己de王妃 提交于 2020-01-16 04:31:38
问题 Similar to this question I would like to both blend colors, and bitmaps (png or bmp, but in my case I'm using a png) while preserving transparency. As with the linked question, I would like to (a) not use third party libraries, (b) use VCL built in techniques where possible but with recourse to the Win32 GDI APIs where needed, and (c) not use GDI+. This simple code, based on the code in the linked question I see that the color blending works but the PNG file's transparency is not preserved,

C#的GDI画图

我的梦境 提交于 2020-01-16 02:02:29
//在窗体重新绘制的时候,重新加载划线 private void Form1_Paint ( object sender , PaintEventArgs e ) { //创建GDI图像 Graphics graphics = this . CreateGraphics ( ) ; //创建画笔对象 Pen pen = new Pen ( Brushes . Red ) ; //创建两个点 Point p1 = new Point ( 30 , 50 ) ; Point p2 = new Point ( 300 , 500 ) ; //调用GDI方法开始画直线 graphics . DrawLine ( pen , p1 , p2 ) ; } private void button1_Click ( object sender , EventArgs e ) { //创建GDI图像 Graphics graphics = this . CreateGraphics ( ) ; //创建画笔对象 Pen pen = new Pen ( Brushes . Red ) ; //创建两个点 Point p1 = new Point ( 30 , 50 ) ; Point p2 = new Point ( 300 , 500 ) ; //调用GDI方法开始画直线 graphics .