本文整理汇总了C++中gdiplus::Bitmap::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::Clone方法的具体用法?C++ Bitmap::Clone怎么用?C++ Bitmap::Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Bitmap
的用法示例。
在下文中一共展示了Bitmap::Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractBitmap
Bitmap CanvasGdiplus::ExtractBitmap() const
{
DCHECK(!mem_bitmap_.IsNull());
// 生成一个位图, 绘制画布内容到其中并返回.
Gdiplus::Bitmap* bitmap = mem_bitmap_.GetNativeBitmap();
Gdiplus::Rect rc_bitmap(0, 0, bitmap->GetWidth(), bitmap->GetHeight());
return Bitmap(bitmap->Clone(rc_bitmap, bitmap->GetPixelFormat()));
}
示例2: IrisDrawText
void IrisBitmap::IrisDrawText(const IrisFont* fontIris, int x, int y, int width, int height, wstring str, int align){
this->needRefreshTexture = true;
if (x > this->width || y > this->height || x < 0 || y < 0)
return;
//this->needRefreshTexture = true;
int size = IrisFont::defaultSize;
IrisColor *color;
wstring name;
bool bold, shadow, italic;
if(fontIris == NULL){
name = IrisFont::defaultName;
bold = IrisFont::defaultBold;
shadow = IrisFont::defaultShadow;
italic = IrisFont::defaultItalic;
color = IrisFont::defaultColor;
}
else
{
name = fontIris->name;
bold = fontIris->bold;
shadow = fontIris->shadow;
italic = fontIris->italic;
color = fontIris->color;
}
// release
Gdiplus::Bitmap *tBitmap = this->bitmap->Clone(0, 0, this->bitmap->GetWidth(), this->bitmap->GetHeight(), PixelFormat32bppARGB);
Graphics tg(tBitmap);
Gdiplus::FontFamily fontFamily(name.c_str());
int fs = FontStyleRegular;
if(bold)
fs |= FontStyleBold;
if(italic)
fs |= FontStyleItalic;
//lfont.lfWeight = 1000;
Gdiplus::Font font(&fontFamily, (REAL)size, fs, UnitPixel);
StringFormat strFormat;
switch(align){
case 0:
strFormat.SetAlignment(StringAlignmentNear);
break;
case 1:
strFormat.SetAlignment(StringAlignmentCenter);
break;
}
Brush *brush;
if(shadow)
brush = new HatchBrush(HatchStyle90Percent, Color(color->red, color->green, color->blue));
else
brush = new SolidBrush(Color(color->red, color->green, color->blue));
strFormat.SetFormatFlags(StringFormatFlagsNoWrap);
Gdiplus::RectF r((REAL)x, (REAL)y, (REAL)width, (REAL)height);
tg.SetSmoothingMode(SmoothingModeAntiAlias);
tg.SetInterpolationMode(InterpolationModeHighQualityBicubic);
Gdiplus::GraphicsPath path;
path.AddString(str.c_str(), str.size(), &fontFamily, FontStyleRegular, 20, r, &strFormat);
Gdiplus::Pen pen(Color(color->red, color->green, color->blue), 2);
tg.DrawPath(&pen, &path);
tg.FillPath(brush, &path);
if(this->bitmap != 0){
delete this->bitmap;
this->bitmap = 0;
}
this->bitmap = tBitmap->Clone(0, 0, tBitmap->GetWidth(), tBitmap->GetHeight(), PixelFormat32bppARGB);
//CLSID encoderClsid;
//ModuleIrisGraphics::GetEncoderClsid(L"image/png", &encoderClsid);
//this->bitmap->Save(L"string.png", &encoderClsid, NULL);
delete brush;
delete tBitmap;
}
示例3: IrisDrawText
void IrisBitmap::IrisDrawText(const IIrisFont* fontIris, int x, int y, int width, int height, wstring str, int align){
this->needRefreshTexture = true;
Gdiplus::Bitmap *tBitmap = this->bitmap->Clone(0, 0, this->bitmap->GetWidth(), this->bitmap->GetHeight(), PixelFormat32bppARGB);
Graphics tg(tBitmap);
int size = IrisFont::defaultSize;
IrisColor *color;
wstring name;
bool bold, shadow, italic;
if(fontIris == NULL){
name = IrisFont::defaultName;
bold = IrisFont::defaultBold;
shadow = IrisFont::defaultShadow;
italic = IrisFont::defaultItalic;
color = (IrisColor*)IrisFont::defaultColor;
}
else
{
name = ((IrisFont*)fontIris)->name;
bold = ((IrisFont*)fontIris)->bold;
shadow = ((IrisFont*)fontIris)->shadow;
italic = ((IrisFont*)fontIris)->italic;
color = (IrisColor*)((IrisFont*)fontIris)->color;
}
FontFamily fontFamily(name.c_str());
int fs = FontStyleRegular;
if(bold)
fs |= FontStyleBold;
if(italic)
fs |= FontStyleItalic;
Font font(&fontFamily, (REAL)size, fs, UnitWorld);
StringFormat strFormat;
switch(align){
case 0:
strFormat.SetAlignment(StringAlignmentNear);
break;
case 1:
strFormat.SetAlignment(StringAlignmentCenter);
break;
}
Brush *brush;
if(shadow)
brush = new HatchBrush(HatchStyle90Percent, Color(color->red, color->green, color->blue));
else
brush = new SolidBrush(Color(color->red, color->green, color->blue));
Color keyColor;
if(color->red == 0 || color->blue == 0 || color-> green == 0)
keyColor = Color::MakeARGB(255, 255, 255, 255);
else
keyColor = Color::MakeARGB(255, color->red - 1, color->green - 1, color->blue - 1);
Gdiplus::PointF point((REAL)x, (REAL)y);
strFormat.SetFormatFlags(StringFormatFlagsNoWrap);
Gdiplus::RectF r((REAL)x, (REAL)y, (REAL)width, (REAL)height);
tg.DrawString(str.c_str(), str.length(), &font, r, &strFormat, brush);
if(this->bitmap != 0){
delete this->bitmap;
this->bitmap = 0;
}
this->bitmap = tBitmap->Clone(0, 0, tBitmap->GetWidth(), tBitmap->GetHeight(), PixelFormat32bppARGB);
delete brush;
delete tBitmap;
}