I'm using GDI+ in a C/MFC application and I just can't seem to avoid flickering whenever the window is resized. I have already tried these steps: returned TRUE on OnEraseBkGnd; returned NULL on.

The gdi+ sdk has it all. Very nice toolkit and c like. Forged3D world editor. Anonymous May 30, 2003 01:01 AM. I really need to use GDI+ with my Dev-C Win32 application in order to display PNG files because it is the easiest way I know of to display PNG files without using lots of user-created external libraries. C Win32 Button with PNG GDI+. Dev-C - Build Error main.o. Reach out to all the awesome people in our software development community by starting your. In.NET, GDI+ functionality resides in the System.Drawing.dll. Before you start using GDI+ classes, you must add reference to the System.Drawing.dll and import System.Drawing namespace. If you are using Visual Studio.NET for your development, you can add reference to the GDI+ library using following: Creating this project is simple.

-->

Windows provides several C++/COM APIs for graphics. These APIs are shown in the following diagram.

  • Graphics Device Interface (GDI) is the original graphics interface for Windows. GDI was first written for 16-bit Windows and then updated for 32-bit and 64-bit Windows.
  • GDI+ was introduced in Windows XP as a successor to GDI. The GDI+ library is accessed through a set of C++ classes that wrap flat C functions. The .NET Framework also provides a managed version of GDI+ in the System.Drawing namespace.
  • Direct3D supports 3-D graphics.
  • Direct2D is a modern API for 2-D graphics, the successor to both GDI and GDI+.
  • DirectWrite is a text layout and rasterization engine. You can use either GDI or Direct2D to draw the rasterized text.
  • DirectX Graphics Infrastructure (DXGI) performs low-level tasks, such as presenting frames for output. Most applications do not use DXGI directly. Rather, it serves as an intermediate layer between the graphics driver and Direct3D.

Gdi 2b Dev C 2b 2b Download

Direct2D and DirectWrite were introduced in Windows 7. They are also available for Windows Vista and Windows Server 2008 through a Platform Update. For more information, see Platform Update for Windows Vista.

Direct2D is the focus of this module. While both GDI and GDI+ continue to be supported in Windows, Direct2D and DirectWrite are recommended for new programs. In some cases, a mix of technologies might be more practical. For these situations, Direct2D and DirectWrite are designed to interoperate with GDI.

The next sections describe some of the benefits of Direct2D.

Hardware Acceleration

The term hardware acceleration refers to graphics computations performed by the graphics processing unit (GPU), rather than the CPU. Modern GPUs are highly optimized for the types of computation used in rendering graphics. Generally, the more of this work that is moved from the CPU to the GPU, the better.

While GDI supports hardware accleration for certain operations, many GDI operations are bound to the CPU. Direct2D is layered on top of Direct3D, and takes full advantage of hardware acceleration provided by the GPU. If the GPU does not support the features needed for Direct2D, then Direct2D falls back to software rendering. Overall, Direct2D outperforms GDI and GDI+ in most situations.

Transparency and Anti-aliasing

Direct2D supports fully hardware-accelerated alpha-blending (transparency).

GDI has limited support for alpha-blending. Most GDI functions do not support alpha blending, although GDI does support alpha blending during a bitblt operation. GDI+ supports transparency, but the alpha blending is performed by the CPU, so it does not benefit from hardware acceleration.

Hardware-accelerated alpha-blending also enables anti-aliasing. Aliasing is an artifact caused by sampling a continuous function. For example, when a curved line is converted to pixels, aliasing can cause a jagged appearance.[3] Any technique that reduces the artifacts caused by aliasing is considered a form of anti-aliasing. In graphics, anti-aliasing is done by blending edges with the background. For example, here is a circle drawn by GDI and the same circle drawn by Direct2D.

The next image shows a detail of each circle. /picasa-for-mac-os-catalina.html.

The circle drawn by GDI (left) consists of black pixels that approximate a curve. The circle drawn by Direct2D (right) uses blending to create a smoother curve.

GDI does not support anti-aliasing when it draws geometry (lines and curves). GDI can draw anti-aliased text using ClearType; but otherwise, GDI text is aliased as well. Aliasing is particularly noticeable for text, because the jagged lines disrupt the font design, making the text less readable. Although GDI+ supports anti-aliasing, it is applied by the CPU, so the performance is not as good as Direct2D.

Vector Graphics

Direct2D supports vector graphics. In vector graphics, mathematical formulas are used to represent lines and curves. These formulas are not dependent on screen resolution, so they can be scaled to arbitrary dimensions. Vector graphics are particularly useful when an image must be scaled to support different monitor sizes or screen resolutions.

Next

If you do any Win32 programming in C++ then I strongly recommend you learn about GDI+. Although it’s been around for a while now, it doesn’t seem to be well known. It can be great to have on hand even just to illustrate tests and prototypes though.

As it’s object-oriented, it’s much nicer and easier to use than the basic C-style GDI that used to be the norm. It also provides a lot of additional functionality which otherwise was not possible (or at least not easy) with the regular GDI functions alone. For example, proper alpha blending, matrix transformations, file input/output, and loads more. It’s quite easy to setup too.

Unicode

One thing to be aware of first: GDI+ requires Unicode to be enabled. That means that all string literals need to be preceded by L or encased in the TEXT(.) Fujitsu keyboard driver. macro. It also means that you might find you need to change any string classes or functions. It can be a nightmare to port existing code, but it’s alright once you get there (or if you’re starting from scratch).

Configure the Project

I’m using Visual C++ Express Edition 2008, which is free to download and use. The best thing to do is setup a simple windows application first. Just create a basic window, and your regular message pump/handler.

Next, you need to make sure Unicode is enabled for your code. To do that, go into your project properties page, select “C/C++” → “Preprocessor”, and beside “Preprocessor Definitions”, add “UNICODE”. Do this for Debug and Release modes, or whatever your configurations are.

After that, you need to link to the Gdiplus library. Still in Project Properties, go to “Linker” → “Input”, and beside “Additional Dependencies”, add “gdiplus.lib”. (Once again, do it for all configurations.)

Initialisation and cleanup

Now you need to add the code to initialise and cleanup the GDI+ system. Put the following code somewhere near the start of your WinMain function (before you create any windows):

Next, put the following code somewhere near the end of your WinMain function, after all other GDI+ objects have been deleted or fallen out of scope:

Finally, somewhere near the top of your source code file(s) where you will be using GDI+, you’ll want to put this:

How to use it

Gdi 2b Dev C 2b 2b C

You’ll usually want to use GDI+ in your window’s “paint” event (although it can be used to write out to files too if you want). The main class you’ll be working with is the Graphics class which handles most of your drawing.

You have to start by getting a Graphics object linked to the device context of your window so it can draw to it safely. There’s lots of ways to handle a paint event, but I’ll follow my preferred approach here (remember to make sure you’re window area is invalidated before doing this):

Gdi 2b Dev C 2b 2b Tutorial

Just like with the regular GDI, you draw and paint using pens and brushes, but thankfully these are much easier. We will fill in a rectangle with a red brush, and draw a green circle inside it:

Finally, we need to tell our window to finish painting now (this bit isn’t GDI+):

Documentation

As you can see, it’s fairly easy to setup and use GDI+. I recommend looking at the GDI+ documentation on MSDN to help you get going.

Coments are closed
Scroll to top