A class provided by a group in the. net environment to replace the GDI graphic functions. In the future, the GDI graphic functions will be gradually replaced.
If you use the gdi + graphic function in vc6.0, follow these steps:
1. download the following rarfile and copy the uplodes and Lib files to the uplodes and Lib folders in the vc directory.
2. Create a new project (taking the winsdk framework as an example, the same is true for mfc)
Add the following code to the StdAfx. h header file:
// Added header file
# Include <comdef. h> // initialize the comport.
# Ifndef ULONG_PTR
# Define ULONG_PTR unsigned long *
# Include "GdiPlus. h"
Using namespace Gdiplus;
# Endif
// End
3. Add in program Initialization
// Two variables used by gdi +
GdiplusStartupInput m_gdiplusStartupInput;
ULONG_PTR m_pGdiToken;
// Load gdi +
GdiplusStartup (& m_pGdiToken, & m_gdiplusStartupInput, NULL );
4. Add it before exiting the program
// Uninstall gdi +
GdiplusShutdown (m_pGdiToken );
5. Add gdiplus. lib to Project> stting> Link> Object/libary.
After completing the steps above, we can use GDI + in the program. Please try it first!
Display a transparent string
Graphics mygraphics (hdc); // create a Graphics object
SolidBrush brush (Color (0,255, 0,); // create a brush. The first item is transparency. The last three items are RGB values.
FontFamily fontFamily (L "Latha"); select a font
Font font (& fontFamily, 1, FontStyleRegular, UnitInch );
PointF pointF (5, 5 );
Mygraphics. DrawString (L "Hello Word! ",-1, & font, pointF, & brush );
Or display a jpg image.
Graphics imgraphics (hdc );
Image image (L "001.jpg ");
Imgraphics. DrawImage (& image, 0, 0 );
Upload 001.jpg to the project directory