D2d1_size_f size = m_sphwndrt-> getsize ();
Float width = size. width, height = size. height;
// Create WIC bitmap...
Ccomptr <id2d1rendertarget> spbitmaprt;
Cwicbitmap wicbitmap;
IFR (wicbitmap. Create (m_spd2dfactory, m_spwicimagingfactory, width, height, & spbitmaprt ));
// Copy the content in the hwndrendertarget to d2d1bitmap
D2d1_pixel_format pixelformat = pixelformat (
Dxgi_format_b8g8r8a8_unorm,
D2d1_alpha_mode_premultiplied );
Ccomptr <id2d1bitmap> spcopybitmap;
IFR (spbitmaprt-> createbitmap (
Sizeu (width, height ),
Bitmapproperties (pixelformat ),
& Spcopybitmap ));
D2d1_point_2u destpoint = point2u ();
D2d1_rect_u srcrect = rectu (0, 0, width, height );
IFR (spcopybitmap-> copyfromrendertarget (& destpoint, m_sphwndrt, & srcrect ));
Ccomptr <idwritetextformat> sptextformat;
IFR (createtextformat (m_spdwritefactory, & sptextformat, _ T ("Microsoft yahei"), 32 ));
Ccomptr <id2d1solidcolorbrush> sptextbrush;
IFR (spbitmaprt-> createsolidcolorbrush (colgrading: red), & sptextbrush ));
Systemtime st;
: Getlocaltime (& St );
Cstring text;
Text. Format (_ T ("File Path: % s \ nsave time: % 2D: % 2D: % 2D"),
Filepath, st. whour, st. wminute, st. wsecond );
// Drawing...
Spbitmaprt-> begindraw ();
Spbitmaprt-> clear (collf: white, 0 ));
Spbitmaprt-> drawbitmap (spcopybitmap, rectf (0, 0, width, height ));
Spbitmaprt-> drawtext (
Text,
Text. getlength (),
Sptextformat,
Rectf (0, 0, width/4, height ),
Sptextbrush );
Spbitmaprt-> enddraw ();
// Save the plot as an image file...
IFR (wicbitmap. saveasbitmapfile (filepath ));