gdi

Unable to capture data from Back Buffer (DirectX9)

一曲冷凌霜 提交于 2019-12-10 11:20:53
问题 I am trying to find the fastest method to take the screenshot. So far I've figured out that either GDI, or DirectX can be used. Using GDI I am able to capture the screen in 35ms, while using DirectX Front buffer it takes 73ms average. I want even faster method than this. For this purpose capturing Back Buffer in DirectX seems to be a good method. I am using the following code to do the same: D3DDISPLAYMODE ddm; D3DPRESENT_PARAMETERS d3dpp; if((g_pD3D=Direct3DCreate9(D3D_SDK_VERSION))==NULL) {

How to fill enclosed area in the Bitmap object with a color

倾然丶 夕夏残阳落幕 提交于 2019-12-10 10:56:41
问题 Give point within the region with a color to fill the region, similar to the "drawing" in the paint bucket function. The. NET Framework, there is no direct equivalent. but i hope use C# to do it. is it possible? 回答1: Here's a very naive flood fill algorithm that should get you started void Form1_Paint(object sender, PaintEventArgs e) { using (Bitmap bitmap = new Bitmap(500, 500)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.Clear(Color.White); List<Point> points = new List<Point>();

How do I fix the alpha value after calling GDI text functions?

守給你的承諾、 提交于 2019-12-10 10:56:26
问题 I have a application that uses the Aero glass effect, so each pixel has an alpha value in addition to red, green, and blue values. I have one custom-draw control that has a solid white background (alpha = 255). I would like to draw solid text on the control using the GDI text functions. However, these functions set the alpha value to an arbitrary value, causing the text to translucently show whatever window is beneath my application's. After calling rendering the text, I would like to go

c# GDI+简单绘图(二)

亡梦爱人 提交于 2019-12-10 06:30:03
在上一片里已经向大家介绍了如何使用GDI+绘制简单的图像,这一片继续向大家介绍其它一些绘图知识. 1. 首先我们来看下上一片中我们使用过的Pen. Pen的属性主要有: Color(颜色),DashCap(短划线终点形状),DashStyle(虚线样式),EndCap(线尾形状), StartCap(线头形状),Width(粗细)等. 我们可以用Pen 来画虚线,带箭头的直线等 Pen p = new Pen(Color.Blue, 5);//设置笔的粗细为,颜色为蓝色 Graphics g = this.CreateGraphics(); //画虚线 p.DashStyle = DashStyle.Dot;//定义虚线的样式为点 g.DrawLine(p, 10, 10, 200, 10); //自定义虚线 p.DashPattern = new float[] { 2, 1 };//设置短划线和空白部分的数组 g.DrawLine(p, 10, 20, 200, 20); //画箭头,只对不封闭曲线有用 p.DashStyle = DashStyle.Solid;//恢复实线 p.EndCap = LineCap.ArrowAnchor;//定义线尾的样式为箭头 g.DrawLine(p, 10, 30, 200, 30); g.Dispose(); p.Dispose();

C# GDI+ 简单绘图 (三)

核能气质少年 提交于 2019-12-10 03:46:52
家的支持,这几天从早忙到晚,一个字累呀!!!现在挺困的,但是又不习惯这么早睡觉,哎~~还是利用这个时间继续来写第三篇吧.   前两篇已经基本向大家介绍了绘图的基本知识.那么,我就用我们上两篇所学的,做几个例子.   我们先来做一个简单的----仿QQ截图,关于这个的例子其实网上已经有这方面的资料了,但是为了文章的完整性,还是觉得有必要讲解.   我们先来看一下效果: (图1) (图2)   接下来看看这是如何做到的.    思路:聊天窗体上有一个截图按钮,点击按钮后,程序将整个屏幕画在一个新的全屏窗体上,然后显示这个窗体.因为是全屏的窗体,并且隐藏了菜单栏、工具栏等,所以在我们看来就好像是一个桌面的截图,然后在这个新窗体上画矩形,最后保存矩形中的内容并显示在原来的聊天窗体中.   步骤:   A.新建一个窗体.命名为Catch.然后设置这个窗体的FormBorderStyle为None,WindowState为Maximized.   B.我们对代码进行编辑: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms

Modify properties for printer-specific configuration dialog

♀尐吖头ヾ 提交于 2019-12-09 19:41:51
问题 We have build a custom print dialog that has a button for showing the printer specific dialog. I read this answer by Shurup, and it helped me to achieve this. ( Edit: But it contains an error, as explained in my answer) However, we use this in combination with stored settings. When we call the method with our PrinterSettings they get ignored. The native dialog shows its default settings, regardless of the provided settings object. EDIT: Removed my fail-code. 回答1: Thanks to this page I found a

GDI handles in a DotNET application

时光毁灭记忆、已成空白 提交于 2019-12-09 18:15:09
问题 My pure DotNET library runs as a plugin inside an unmanaged desktop application. I've been getting a steady (though low) stream of crash reports that seem to indicate a problem with GDI handles (fonts in error messages etc. revert to the system font, display of all sorts of controls break down, massive crash shortly after). My Forms have few controls, but I do a lot of GDI+ drawing in User controls. What's a good way to tell how many handles I'm using, or even leaking? Thanks, David 回答1: I've

c# GDI+简单绘图(四)

拥有回忆 提交于 2019-12-09 17:44:08
  前几篇我已经向大家介绍了如何使用GDI+来绘图,并做了一个截图的实例,这篇我向大家介绍下如何来做一个类似windows画图的工具.   个人认为如果想做一个功能强大的绘图工具,那么单纯掌握GDI还远远不够,我的目前也只能做一个比较简单的绘图工具了.不足之处,欢迎大家讨论!   先来看一下最终效果吧:      主要实现功能:画直线,矩形,橡皮,圆形,切换颜色,打开图片,保存图片,清除图片,手动调节画布大小;软件刚启动时,为一张空白画布,我们可以直接在画布上绘画,也可以通过菜单中的“打开”,导入一张图片,然后我们就可以在这张图片上进行绘制。   平台:VS2005 WINFORM   由于代码过多,在这里只简要介绍下制作步骤,提供大家工程下载.   1.对整个界面进行布局.   2.实现绘图工具的功能   3.实现颜色拾取的功能,这里我们直接拿上次写的自定义控件来用.   4.实现菜单功能   5.实现手动调节画布大小的功能   6.测试    实现绘图工具的功能   为了让代码藕合度小点,稍许用了些设计模式,因为不是很会,所以代码还是有点乱乱的,嘿嘿!关于绘图工具的这些功能块全部写在了DrawTools这个类里.那么在主窗体中,只需要调用这个类来完成绘制就行了,而不需要过多的涉及到具体的绘图代码。绘图工具这个类提供的主要工具就是:铅笔、橡皮、直线、矩形、圆形、实心矩形、实心圆形

draw on desktop using visual c++

ε祈祈猫儿з 提交于 2019-12-09 13:01:47
问题 I am writing an opencv application to draw using laser beam using visual studio VC++ console application. I want to draw lines on desktop. I know that the drawing functions are available in GDI32.dll , but confused on how to integrate GDI32.dll with my vc code. can you suggest some good solution? 回答1: The code below draws a blue rectangle on the desktop. #include <iostream> #include <Windows.h> int main() { /* hide console window */ ShowWindow(FindWindowA("ConsoleWindowClass", NULL), false);

Win32: Does a window have the same HDC for its entire lifetime?

与世无争的帅哥 提交于 2019-12-09 06:28:52
问题 Am i allowed to use a DC outside of a paint cycle? Is my window's DC guaranteed to be valid forever? i'm trying to figure out how long my control's Device Context (DC) is valid. i know that i can call: GetDC(hWnd); to get the device context of my control's window, but is that allowed? When Windows sends me a WM_PAINT message, i am supposed to call BeginPaint/EndPaint to properly acknowledge that i've painted it, and to internally clear the invalid region: BeginPaint(hWnd, {out}paintStruct);