GDI+ double buffering in C++

I haven't written anything with GDI for a while now (and never with GDI+), and I'm just working on a fun project, but for the life of me, I can't figure out how to double buffer GDI+ void DrawStuff(HWND hWnd) { HDC hdc; HDC hdcBuffer; PAINTSTRUCT ps; hdc = BeginPaint(hWnd, &ps); hdcBuffer = CreateCompatibleDC(hdc); Graphics graphics(hdc)

GDI + C ++中的双缓冲

我现在还没有用GDI写过任何东西(而且从来没有用过GDI +),而我只是在开发一个有趣的项目,但在我的生活中,我无法弄清楚如何将缓冲区GDI + void DrawStuff(HWND hWnd) { HDC hdc; HDC hdcBuffer; PAINTSTRUCT ps; hdc = BeginPaint(hWnd, &ps); hdcBuffer = CreateCompatibleDC(hdc); Graphics graphics(hdc); graphics.Clear(Color::Black); // drawing stuff, i.e.

Drawing in window while resizing leaves Unpainted border

The problem that I have seems to be trivial, but I cannot find a way to solve it. Here it is. I have a window with some graphics in it. For simplicity lets say it's a solid green rectangle which fills the entire client area of the window. I want this rectangle to be redrawn and to fill the entire window every time the window changes its size. What I did originally was this. I posted WM

调整大小时在窗口中绘制未涂漆的边框

我所遇到的问题似乎微不足道,但我找不到解决问题的方法。 这里是。 我有一个窗口,里面有一些图形。 为了简单起见,我们可以说它是一个坚实的绿色矩形,可以填充整个窗口的客户区域。 我想要重绘这个矩形并在每次窗口改变大小时填充整个窗口。 我最初做的是这个。 我从WM_SIZE处理程序发布了WM_PAINT消息。 它可以工作,但如果我快速移动鼠标,我会在绿色矩形周围看到一些未涂漆(白色)区域(实际上只有一个或两个边

Converting Color Bitmap to Grayscale in C++

Need to convert a color bitmap to a grey scale. Here is the approach: HDC hdcWindow = GetDC(hWnd); HBITMAP hDIBBitmap; { // Create a compatible DC which is used in a BitBlt from the window DC HDC hdcMemDC = CreateCompatibleDC(hdcWindow); SelectObject(hdcMemDC, bmHatch); BITMAPINFO bmi; memset(&b

在C ++中将彩色位图转换为灰度

需要将颜色位图转换为灰度。 这是方法: HDC hdcWindow = GetDC(hWnd); HBITMAP hDIBBitmap; { // Create a compatible DC which is used in a BitBlt from the window DC HDC hdcMemDC = CreateCompatibleDC(hdcWindow); SelectObject(hdcMemDC, bmHatch); BITMAPINFO bmi; memset(&bmi, 0, sizeof(BITMAPINFO));

How do I do high quality scaling of a image?

I'm writing some code to scale a 32 bit RGBA image in C/C++. I have written a few attempts that have been somewhat successful, but they're slow and most importantly the quality of the sized image is not acceptable. I compared the same image scaled by OpenGL (ie my video card) and my routine and it's miles apart in quality. I've Google Code Searched, scoured source trees of any

如何对图像进行高质量缩放?

我正在编写一些代码来在C / C ++中缩放32位RGBA图像。 我已经写了一些有些成功的尝试,但它们速度很慢,最重要的是尺寸图像的质量不可接受。 我比较了OpenGL(即我的视频卡)和我的例程缩放的相同图像,它的质量相差数英里。 我搜索了谷歌代码,搜索了一些我认为可以点亮的东西(SDL,Allegro,wxWidgets,CxImage,GD,ImageMagick等等)的源代码树,但通常他们的代码要么复杂而且散布在各处,汇编程序,很少或没有评论。

Methods for encrypting an archive in C++

I'm writing a game that will have a lot of information (configuration, some content, etc) inside of some xml documents, as well as resource files. This will make it easier for myself and others to edit the program without having to edit the actual C++ files, and without having to recompile. However, as the program is starting to grow there is an increase of files in the same directory as t

用C ++加密档案的方法

我正在编写一个游戏,它会在一些XML文档以及资源文件中包含大量信息(配置,一些内容等)。 这将使我和其他人更容易编辑程序,而无需编辑实际的C ++文件,也无需重新编译。 但是,随着程序开始增长,与程序在同一目录中的文件数量增加。 所以我想把它们放在一个文件档案里面(因为它们大多是文本,压缩效果很好)。 我的问题是这样的:压缩所有文件和: 设置密码(如密码保护的ZIP),然后在程序需要时提供密码 使用Cr

How to generate a 64 bit COM Proxy

I have a 32 bit COM server (and the source code for it) The source generates the server and a 32 bit proxy stub. (The MIDL compiler generates the proxy stub code.) I would like to make a 64 bit proxy as well, so that 64 bit programs can talk to my 32 bit COM server. How do I go about converting a 32 bit proxy into a 64 bit proxy that talks to a 32 bit process? I'm guessing that just rec

如何生成一个64位COM代理

我有一个32位COM服务器(及其源代码)源生成服务器和一个32位代理存根。 (MIDL编译器生成代理存根代码。) 我想制作一个64位代理,以便64位程序可以与我的32位COM服务器通信。 我该如何将32位代理转换为与32位进程对话的64位代理? 我猜只是用/ D:_M_AMD64重新编译是不够的。 由MIDL编译器生成的代理代码应该可以工作。 你只需要从该代码构建一个64位的dll。 确保你的类型被正确定义。 确保避免类似UINT_PTR的类型

Documenting callback typedefs in Doxygen

I have the following typedef: typedef void( __cdecl *tCallback )( const char* Message ); How would I document that correctly using Doxygen? I would like to to have the tCallback documented and the parameters expected documented. A simple example: /// typedef test typedef test bool produces correct output in doxygen //typedef tCallback typedef void( __cdecl *tCallback )( const char* Messa

记录Doxygen中的回调typedefs

我有以下typedef: typedef void( __cdecl *tCallback )( const char* Message ); 我如何使用Doxygen正确记录该文件? 我想将tCallback记录下来,并将参数预期记录下来。 一个简单的例子: /// typedef test typedef test bool 在doxygen中产生正确的输出 //typedef tCallback typedef void( __cdecl *tCallback )( const char* Message ); 生产: C:/test.cpp:2: warning: Found ';' while parsing initializer list!

Questions about operator overloading

I have two questions about operator overloading. For an iterator type, how is operator-> overloaded? What value should it return assuming that it is an iterator for a collection of class T objects? Why does operator++() return by class T& while operator++(int) return by class T ? I understand these two represent prefix increment and postfix increment. But why the difference in retur

有关运算符重载的问题

我有两个关于运算符重载的问题。 对于迭代器类型, operator->如何重载? 假设它是一个class T对象集合的迭代器,它应该返回什么值? 为什么operator++()通过class T&返回,而operator++(int)通过class T返回? 我明白这两个代表前缀增量和后缀增量。 但为什么回报价值的差异? 编辑:为Alf。 代码虽然功能尚未完成。 欢迎任何有待改进的建议。 #ifndef DHASH_H #define DHASH_H //#include <vector> #

safe singleton in C++

The usual pattern for a singleton class is something like static Foo &getInst() { static Foo *inst = NULL; if(inst == NULL) inst = new Foo(...); return *inst; } However, it's my understanding that this solution is not thread-safe, since 1) Foo's constructor might be called more than once (which may or may not matter) and 2) inst may not be fully constructed before it i

C ++中的安全单例

单身类的通常模式是类似的 static Foo &getInst() { static Foo *inst = NULL; if(inst == NULL) inst = new Foo(...); return *inst; } 然而,我的理解是这个解决方案不是线程安全的,因为1)Foo的构造函数可能会被多次调用(这可能会也可能不重要),2)在返回到不同线程之前,inst可能不会被完全构造。 一种解决方法是在整个方法中包装一个互斥锁,但是在我真正需要它之后,我花了很长时间同步开销。

C++ Singleton design pattern

Recently I've bumped into a realization/implementation of the Singleton design pattern for C++. It has looked like this (I have adopted it from the real life example): // a lot of methods are omitted here class Singleton { public: static Singleton* getInstance( ); ~Singleton( ); private: Singleton( ); static Singleton* instance; }; From this declaration I

C ++单例设计模式

最近我遇到了C ++的Singleton设计模式的实现/实现。 它看起来像这样(我从现实生活的例子中采纳了它): // a lot of methods are omitted here class Singleton { public: static Singleton* getInstance( ); ~Singleton( ); private: Singleton( ); static Singleton* instance; }; 从这个声明中,我可以推断实例字段是在堆上启动的。 这意味着有一个内存分配。 对于我来说完全不清楚