当前位置: 首页>>代码示例>>C++>>正文


C++ Bitmap::Clone方法代码示例

本文整理汇总了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()));
    }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:9,代码来源:canvas_gdiplus.cpp

示例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;
	
}
开发者ID:big-moon,项目名称:Iris-2D-Project,代码行数:90,代码来源:IrisBitmap.cpp

示例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;

}
开发者ID:HADESAngelia,项目名称:Iris-2D-Project,代码行数:79,代码来源:IrisBitmap.cpp


注:本文中的gdiplus::Bitmap::Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。