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


C++ ImageAttributes::SetColorMatrix方法代码示例

本文整理汇总了C++中ImageAttributes::SetColorMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageAttributes::SetColorMatrix方法的具体用法?C++ ImageAttributes::SetColorMatrix怎么用?C++ ImageAttributes::SetColorMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageAttributes的用法示例。


在下文中一共展示了ImageAttributes::SetColorMatrix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void CSkinButton2::DrawImage(Gdiplus::Graphics& gdi,BTN_DRAW_HUE hue)
{
	if(hue == DRAW_NORMAL)
	{
		if( m_pPngImage && m_pPngImage->m_pBitmap )
		{
			RectF grect; grect.X=0, grect.Y=0; grect.Width = m_pPngImage->m_pBitmap->GetWidth(); grect.Height = m_pPngImage->m_pBitmap->GetHeight();
			gdi.DrawImage(*m_pPngImage,grect );
		}
	}
	else if(hue == DRAW_LIGHT)
	{
		if( m_pPngImage && m_pPngImage->m_pBitmap )
		{
			ImageAttributes ia;
			ia.SetColorMatrix(&m_LightMat);
			RectF grect; grect.X=0, grect.Y=0; grect.Width = m_pPngImage->m_pBitmap->GetWidth(); grect.Height = m_pPngImage->m_pBitmap->GetHeight();
			gdi.DrawImage(*m_pPngImage, grect, 0, 0, grect.Width, grect.Height, UnitPixel, &ia);
		}
	}
	else if(hue == DRAW_GRAY )
	{
		if( m_pPngImage && m_pPngImage->m_pBitmap )
		{
			ImageAttributes ia;
			ia.SetColorMatrix(&m_GrayMat);
			RectF grect; grect.X=0, grect.Y=0; grect.Width = m_pPngImage->m_pBitmap->GetWidth(); grect.Height = m_pPngImage->m_pBitmap->GetHeight();
			gdi.DrawImage(*m_pPngImage, grect, 0, 0, grect.Width, grect.Height, UnitPixel, &ia);
		}
	}
}
开发者ID:2Dou,项目名称:PlayBox,代码行数:31,代码来源:SkinButton2.cpp

示例2: Render

/*
 * Called by SysStats when the Overlay should render itself
 */
STDMETHODIMP CAnimatorOverlay::Render(LONG _hdc)
{
	// Get state of animation meter
	IMeter *iMeter = 0;
	framecount = 1;
	currentframe = 0;
	get_meter(&iMeter);
	if (iMeter)
	{
		iMeter->GetAsLong(L"framecount", &framecount);
		iMeter->GetAsLong(L"currentframe", &currentframe);
	}

	if (alphaEnd == alpha)
		CompositeOverlayImpl<IAnimatorOverlay>::Render(_hdc);
	else
	{
		// Create a private HDC to draw into so that we can mask it.
		long width = 128;
		long height = 128;
		model->get_Width(&width);
		model->get_Height(&height);
		HDCImage hdc((HDC)_hdc, width, height);

		// Render the composite
		CompositeOverlayImpl<IAnimatorOverlay>::Render(hdc);

		// Copy private HDC into the passed HDC
		Graphics g((HDC)_hdc);
		g.SetInterpolationMode(InterpolationModeHighQuality);
		g.SetSmoothingMode(SmoothingModeAntiAlias);
		float delta = framecount <= 1 ? 0.0 : ((float)currentframe)/(framecount-1.0);
		ColorMatrix colorMatrix = {
						1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
						0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
						0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
						0.0f, 0.0f, 0.0f, ((float)alpha+(alphaEnd-alpha)*delta)/255.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 0.0f, 1.0f};

 		// Create an ImageAttributes object and set its color matrix.
		ImageAttributes imageAtt;
		imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);

		g.DrawImage(
		   &hdc.GetImage(),
		   Rect(0, 0, width, height),	// Destination rectangle
		   0,						// Source rectangle X
		   0,						// Source rectangle Y
		   width,		// Source rectangle width
		   height,		// Source rectangle height
		   UnitPixel,
		   &imageAtt);
	}

	return S_OK;
}
开发者ID:Templier,项目名称:desktopx,代码行数:59,代码来源:AnimatorOverlay.cpp

示例3: DrawImage

BOOL CGif::DrawImage(CDC * pDC, POINT * pPoint, int srcx, int srcy, int srcwidth, int srcheight, float * pfClrAttr)
{
	ASSERT(NULL != m_pImage);
	if (NULL == m_pImage) return 1;

	if (IsNull()) return 2;

	Graphics graph(pDC->GetSafeHdc());

	Gdiplus::Point points[3];

	memset(points, 0, sizeof (points));
	if (NULL == pPoint)
	{
		points[1].X = m_nWidth;
		points[2].Y = m_nHeight;
	}
	else
	{
		for (BYTE i = 0;i < 3;i++)
		{
			points[i].X = pPoint[i].x;
			points[i].Y = pPoint[i].y;
		}
	}
	if ((0 == srcwidth)||(0 == srcheight))
	{
		srcwidth = m_nWidth;
		srcheight = m_nHeight;
	}
	if (NULL == pfClrAttr)
	{
		graph.DrawImage(m_pImage, points, 3, srcx, srcy, srcwidth, srcheight, UnitPixel);
	}
	else
	{
#ifdef _DEBUG
		for (BYTE i = 0;i < 25;i++)
		{
			ASSERT(0 <= pfClrAttr[i]);
		}
#endif
		ColorMatrix colorMatrix;
		memcpy(&colorMatrix, pfClrAttr, sizeof (colorMatrix));

		ImageAttributes imageAttr;
		imageAttr.SetColorMatrix(&colorMatrix);

		graph.DrawImage(m_pImage, points, 3, srcx, srcy, srcwidth, srcheight, UnitPixel, &imageAttr);
	}

	graph.ReleaseHDC(pDC->GetSafeHdc());

	return TRUE;
}
开发者ID:lincoln56,项目名称:robinerp,代码行数:55,代码来源:Gif.cpp

示例4: AlphaDrawImage

//╩Л╨о╩Ф╩╜
bool CPngImageEx::AlphaDrawImage(CDC * pDestDC, INT xDest, INT yDest, INT cxDest, INT cyDest, INT xSrc, INT ySrc, INT cxSrc, INT cySrc, BYTE cbAlphaDepth)
{
	//WIN 7 ж╢пп
	if ( CD2DEngine::GetD2DEngine() )
	{
		CD2DEngine::GetD2DEngine()->DrawImage(m_pWnd, m_strImageName, xDest, yDest, cxDest, cyDest, xSrc, ySrc, cxSrc, cySrc, cbAlphaDepth  );
		return true;
	}

	//╢╢╫╗╩╨ЁЕ
	if ((cxDest!=cxSrc)||(cyDest!=cySrc))
	{
		//╪стьеп╤о
		ASSERT(m_pImage!=NULL);
		if (m_pImage==NULL) return false;

		//╢╢╫╗фад╩
		ASSERT(pDestDC!=NULL);
		Graphics graphics(pDestDC->GetSafeHdc());

		//╧╧тЛн╩жц
		RectF rcDrawRect;
		rcDrawRect.X=(REAL)xDest;
		rcDrawRect.Y=(REAL)yDest;
		rcDrawRect.Width=(REAL)cxDest;
		rcDrawRect.Height=(REAL)cyDest;

		//м╦цВ╬ьуС
		ColorMatrix Matrix=
		{
			1.0f,0.0f,0.0f,0.0f,0.0f, 
				0.0f,1.0f,0.0f,0.0f,0.0f, 
				0.0f,0.0f,1.0f,0.0f,0.0f,
				0.0f,0.0f,0.0f,cbAlphaDepth/255.0f,0.0f, 
				0.0f,0.0f,0.0f,0.0f,1.0f
		};

		//иХжцйТпт
		ImageAttributes Attributes; 
		Attributes.SetColorMatrix(&Matrix,ColorMatrixFlagsDefault,ColorAdjustTypeBitmap); 

		//╩Ф╩╜м╪оЯ
		graphics.DrawImage(m_pImage,rcDrawRect,(REAL)xSrc,(REAL)ySrc,(REAL)cxSrc,(REAL)cySrc,UnitPixel,&Attributes);	
	}
	else
	{
		//фум╗╣Всц
		AlphaDrawImage(pDestDC,xDest,yDest,cxDest,cyDest,xSrc,ySrc,cbAlphaDepth);
	}

	return true;
}
开发者ID:cyrillic7,项目名称:CPFrom,代码行数:53,代码来源:PngImageEx.cpp

示例5: TurnGreyscale

/*
** Turns the image greyscale by applying a greyscale color matrix.
** Note that the returned bitmap image must be freed by caller.
**
*/
Bitmap* TintedImage::TurnGreyscale(Bitmap* source)
{
	ImageAttributes ImgAttr;
	ImgAttr.SetColorMatrix(&c_GreyScaleMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);

	// We need a blank bitmap to paint our greyscale to in case of alpha
	Rect r(0, 0, source->GetWidth(), source->GetHeight());
	Bitmap* bitmap = new Bitmap(r.Width, r.Height, PixelFormat32bppPARGB);

	Graphics graphics(bitmap);
	graphics.DrawImage(source, r, 0, 0, r.Width, r.Height, UnitPixel, &ImgAttr);

	return bitmap;
}
开发者ID:AlonTzarafi,项目名称:rainmeter,代码行数:19,代码来源:TintedImage.cpp

示例6: rc

/*
gamma 参数的典型值在 1.0 到 2.2 之间;但在某些情况下,0.1 到 5.0 范围内的值也很有用。
imageAttr.SetGamma 参数值越大,图像越暗,反之则越亮
*/
Bitmap * HighlightBitmap(Bitmap * pSrc, float fGamma, BOOL bCreate )
{
	if (pSrc == NULL) return NULL;
	if (fGamma <= 0.0f) return NULL;

	RectF rc(0.0f, 0.0f, (float)pSrc->GetWidth(), (float)pSrc->GetHeight());
	if ( rc.IsEmptyArea()) return NULL;

	Bitmap * pResult = !bCreate ? pSrc : new Bitmap( (int)rc.Width, (int)rc.Height, pSrc->GetPixelFormat() );
	if( pResult == NULL ) return NULL;

	Graphics * g = Graphics::FromImage(pResult);
	if ( g == NULL)
	{
		if (bCreate) { delete pResult; pResult = NULL; }
		return NULL;
	}
	
	ImageAttributes imageAttr;

	//////////////////////////////////////////////////////////////////////////
#if TRUE
	imageAttr.SetGamma( 1/fGamma );
#else
	Gdiplus:: ColorMatrix HotMat = 
	{1.05f, 0.00f, 0.00f, 0.00f,0.00f,
	0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
	0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
	0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
	0.05f, 0.05f, 0.05f, 0.00f, 1.00f};
	imageAttr.SetColorMatrix(&HotMat);
#endif
	//////////////////////////////////////////////////////////////////////////

	Status status = g->DrawImage(pSrc, rc, 0, 0, (float)pSrc->GetWidth(), (float)pSrc->GetHeight()
		,Gdiplus:: UnitPixel, &imageAttr);

	delete g; g = NULL;

	if ( Ok != status )
	{
		if (bCreate) { delete pResult; pResult = NULL; }
		return NULL;
	}

	return pResult;
}
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:51,代码来源:GDIPlusInit.cpp

示例7: DrawImage

void CRenderUtility::DrawImage( HDC hDC, Image* pImage, RECT &rctDst, RECT&rctSrc, int nAlpha /*= 255*/ )
{
	if(pImage == NULL || nAlpha == 0) return;

	float fAlpha = (float)nAlpha / 255.0f;
	Graphics	graph(hDC);
	ColorMatrix colorMatrix={1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
		0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 0.0f, fAlpha, 0.0f,
		0.0f, 0.0f, 0.0f, 0.0f, 1.0f};

	ImageAttributes imgAtt;
	imgAtt.SetColorMatrix(&colorMatrix);

	Rect rcDst(rctDst.left, rctDst.top, RECT_WIDTH(rctDst), RECT_HEIGHT(rctDst));
	graph.DrawImage(pImage, rcDst, rctSrc.left, rctSrc.top, RECT_WIDTH(rctSrc), RECT_HEIGHT(rctSrc), UnitPixel, &imgAtt);
}
开发者ID:aliu927,项目名称:LayerWndTest,代码行数:18,代码来源:RenderUtility.cpp

示例8: ApplyTint

/*
** This will apply the Greyscale matrix and the color tinting.
**
*/
void TintedImage::ApplyTint()
{
	bool useColorMatrix = !CompareColorMatrix(m_ColorMatrix, &c_IdentityMatrix);

	if (m_GreyScale || useColorMatrix)
	{
		Bitmap* original = GetImage();
		Bitmap* tint;

		if (m_GreyScale && !useColorMatrix)
		{
			tint = TurnGreyscale(original);
		}
		else
		{
			ImageAttributes ImgAttr;
			ImgAttr.SetColorMatrix(m_ColorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);

			Rect r(0, 0, original->GetWidth(), original->GetHeight());

			tint = new Bitmap(r.Width, r.Height, PixelFormat32bppPARGB);

			Graphics graphics(tint);

			if (m_GreyScale)
			{
				Bitmap* gray = TurnGreyscale(original);
				graphics.DrawImage(gray, r, 0, 0, r.Width, r.Height, UnitPixel, &ImgAttr);
				delete gray;
			}
			else
			{
				graphics.DrawImage(original, r, 0, 0, r.Width, r.Height, UnitPixel, &ImgAttr);
			}
		}

		delete m_BitmapTint;
		m_BitmapTint = tint;
	}
}
开发者ID:AlonTzarafi,项目名称:rainmeter,代码行数:44,代码来源:TintedImage.cpp

示例9: ResizeBitmap

//输入原图片指针的指针,及新图片的新宽高
//示例:ResizeBitmap(&m_pOrignImageS,width,height);
BOOL CExampleDemoDlg::ResizeBitmap(Bitmap **ppImg, int m_NewWidth, int m_NewHeight)
{
	if (ppImg == NULL || *ppImg == NULL)
	{
		return FALSE;
	}

	Bitmap *m_NewImage = new Bitmap(m_NewWidth, m_NewHeight);

	ColorMatrix colorMatrix = {
		1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
		0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
		0.0f, 0.0f, 0.0f, 0.0f, 1.0f };

	ImageAttributes imageAtt;
	imageAtt.SetColorMatrix(&colorMatrix);
	imageAtt.SetWrapMode(WrapModeTileFlipXY);

	Graphics gs(m_NewImage);
	gs.SetSmoothingMode(SmoothingModeAntiAlias);
	gs.SetInterpolationMode(InterpolationModeHighQuality);
	gs.DrawImage(
		(*ppImg),
		Rect(0, 0, m_NewWidth, m_NewHeight),  // Destination rectangle
		0,								   // Source rectangle temp->x 
		0,								   // Source rectangle temp->y
		(*ppImg)->GetWidth(),     // Source rectangle width
		(*ppImg)->GetHeight(),    // Source rectangle height
		UnitPixel,
		&imageAtt);

	//交换指针
	delete (*ppImg);
	(*ppImg) = m_NewImage;
	return TRUE;
}
开发者ID:hjimce,项目名称:EyeLabelDemo,代码行数:40,代码来源:ExampleDemoDlg.cpp

示例10: GDIPlus_AlphaBlend

BOOL GDIPlus_AlphaBlend(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION * bf)
{
	Graphics g(hdcDest);
	BITMAP bmp;
	HBITMAP hbmp = (HBITMAP)GetCurrentObject(hdcSrc, OBJ_BITMAP);
	GetObject(hbmp, sizeof(BITMAP), &bmp);

	Bitmap *bm;
	if (bmp.bmBitsPixel == 32 && bf->AlphaFormat) {
		bm = new Bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmWidthBytes, PixelFormat32bppPARGB, (BYTE*)bmp.bmBits);
		bm->RotateFlip(RotateNoneFlipY);
	}
	else bm = new Bitmap(hbmp, nullptr);

	ImageAttributes attr;
	ColorMatrix Matrix =
	{
		1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
		0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 0.0f, ((float)bf->SourceConstantAlpha) / 255, 0.0f,
		0.0f, 0.0f, 0.0f, 0.0f, 1.0f
	};
	attr.SetColorMatrix(&Matrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);

	if (bf->BlendFlags & 128 && nWidthDest < nWidthSrc && nHeightDest < nHeightSrc) {
		g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
		g.SetPixelOffsetMode(PixelOffsetModeHalf);
		attr.SetGamma((REAL)0.8, ColorAdjustTypeBitmap);
	}
	else g.SetInterpolationMode(InterpolationModeLowQuality);

	RectF rect((float)nXOriginDest, (float)nYOriginDest, (float)nWidthDest, (float)nHeightDest);
	g.DrawImage(bm, rect, (float)nXOriginSrc, (float)nYOriginSrc, (float)nWidthSrc, (float)nHeightSrc, UnitPixel, &attr, nullptr, nullptr);
	delete bm;
	return TRUE;
}
开发者ID:tweimer,项目名称:miranda-ng,代码行数:37,代码来源:modern_gdiplus.cpp

示例11: DrawAvatarImageWithGDIp

void DrawAvatarImageWithGDIp(HDC hDestDC, int x, int y, DWORD width, DWORD height, HBITMAP hbmp, int x1, int y1, DWORD width1, DWORD height1, DWORD flag, BYTE alpha)
{
	BITMAP bmp;
	Bitmap *bm;
	BYTE * bmbits = nullptr;
	GetObject(hbmp, sizeof(BITMAP), &bmp);
	Graphics g(hDestDC);
	if (bmp.bmBitsPixel == 32 && (flag&AVS_PREMULTIPLIED)) {
		bmbits = (BYTE*)bmp.bmBits;
		if (!bmbits) {
			bmbits = (BYTE*)malloc(bmp.bmHeight*bmp.bmWidthBytes);
			GetBitmapBits(hbmp, bmp.bmHeight*bmp.bmWidthBytes, bmbits);
		}
		bm = new Bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmWidthBytes, PixelFormat32bppPARGB, bmbits);
		bm->RotateFlip(RotateNoneFlipY);
		if (!bmp.bmBits) {
			bm->RotateFlip(RotateNoneFlipY);
			free(bmbits);
		}
	}
	else bm = new Bitmap(hbmp, nullptr);

	ImageAttributes attr;
	ColorMatrix Matrix =
	{
		1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
		0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
		0.0f, 0.0f, 0.0f, ((float)alpha) / 255, 0.0f,
		0.0f, 0.0f, 0.0f, 0.0f, 1.0f
	};
	attr.SetColorMatrix(&Matrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
	g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
	RectF rect((float)x, (float)y, (float)width, (float)height);
	g.DrawImage(bm, rect, (float)x1, (float)y1, (float)width1, (float)height1, UnitPixel, &attr, nullptr, nullptr);
	delete bm;
}
开发者ID:tweimer,项目名称:miranda-ng,代码行数:37,代码来源:modern_gdiplus.cpp

示例12: InitImageAttributes

// ***************************************************************
//		InitImageAttributes()
// ***************************************************************
void TilesDrawer::InitImageAttributes(TileManager* manager, ImageAttributes& attr)
{
	attr.SetWrapMode(WrapModeTileFlipXY);

	if (!manager->IsBackground())
	{
		Gdiplus::ColorMatrix m = ImageHelper::CreateMatrix(manager->contrast,
			manager->brightness,
			manager->saturation,
			manager->hue,
			0.0f, RGB(255, 255, 255), false, manager->get_Alpha() / 255.0f);

		attr.SetColorMatrix(&m);

		if (manager->useTransparentColor)
		{
			Gdiplus::Color color(GetRValue(manager->transparentColor),
								 GetGValue(manager->transparentColor),
								 GetBValue(manager->transparentColor));

			attr.SetColorKey(color, color);
		}
	}
}
开发者ID:liuzhumei,项目名称:MapWinGIS,代码行数:27,代码来源:TilesDrawer.cpp

示例13: DrawHighlight

void DrawHighlight( Image * pImage, Graphics * pGraphics, RectF rcDraw, float fGamma /*= 2.2f */ )
{
	if (pGraphics == NULL) return;
	if (pImage == NULL) return;

	ImageAttributes imageAttr;
	//////////////////////////////////////////////////////////////////////////
#if FALSE
	imageAttr.SetGamma( 1/fGamma );
#else
	Gdiplus:: ColorMatrix HotMat = 
	{1.05f, 0.00f, 0.00f, 0.00f,0.00f,
	0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
	0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
	0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
	0.05f, 0.05f, 0.05f, 0.00f, 1.00f};
	imageAttr.SetColorMatrix(&HotMat);
#endif
	//////////////////////////////////////////////////////////////////////////

	RectF rc (0.0f, 0.0f, (float)pImage->GetWidth(), (float)pImage->GetHeight());
	pGraphics->DrawImage( pImage, rcDraw, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height
		, Gdiplus:: UnitPixel, &imageAttr );
}
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:24,代码来源:GDIPlusInit.cpp

示例14: WndProc

//
// 윈도우 프로시져 함수 ( 메시지 큐에서 받아온 메시지를 처리한다 )
//
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	PAINTSTRUCT ps;
	HDC hdc;

	switch (msg)
	{
	case WM_PAINT: // 화면이 갱신될 때 호출된다.
		{
			hdc = BeginPaint(hWnd, &ps);

			Graphics *graph = Graphics::FromImage(g_bmp);

			RECT cr;
			GetClientRect(hWnd, &cr);
			Rect wndSize(cr.left, cr.top, cr.right, cr.bottom);

			graph->DrawImage(g_image, wndSize);

			graph->FillRectangle(g_yellowBrush, g_block);
			graph->FillRectangle(g_yellowBrush, g_block2);


			graph->DrawImage(g_image2, g_bullet, 
				g_bulletSrc.X, g_bulletSrc.Y, g_bulletSrc.Width, g_bulletSrc.Height,
				UnitPixel);


			float fBlend = 1.f; //set the alpha value
			ColorMatrix BitmapMatrix = {
				1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
				0.0f, 0.0f, 0.0f, fBlend, 0.0f,
				0.0f, 0.0f, 0.0f, 0.0f, 1.0f
			};

			ImageAttributes ImgAttr;
			ImgAttr.SetColorMatrix(&BitmapMatrix,
				ColorMatrixFlagsDefault,
				ColorAdjustTypeBitmap);

			//graph->SetCompositingMode(CompositingModeSourceCopy);
			if (g_isCollision)
			{
				graph->DrawImage(g_image3, g_bullet, 
					g_explosion.X, g_explosion.Y, g_explosion.Width, g_explosion.Height,
					UnitPixel, &ImgAttr);
			}

//			graph->DrawImage(g_image3, g_bullet, 
//				g_explosion.X, g_explosion.Y, g_explosion.Width, g_explosion.Height,
//				UnitPixel);


			DrawString(graph, 50, 0, frameStr);

			g_graphics->DrawImage(g_bmp, wndSize);


			EndPaint(hWnd, &ps);
		}
		break;

//	case WM_ERASEBKGND:
//		return 0;

	case WM_LBUTTONDOWN:
		{
			g_IsClick = true;
			g_mouseClickPos = Point(LOWORD(lParam), HIWORD(lParam));
		}
		break;

	case WM_LBUTTONUP:
		{
			g_IsClick = false;
		}
		break;

	case WM_MOUSEMOVE:
		{
		}
		break;

	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_LEFT:
		case VK_UP:
			++g_hatchStyle;
			break;

		case VK_RIGHT:
		case VK_DOWN:
			--g_hatchStyle;
			break;
//.........这里部分代码省略.........
开发者ID:sgajaejung,项目名称:C-Cplusplus-Lecture-Beginner,代码行数:101,代码来源:gradius.cpp

示例15: paint


//.........这里部分代码省略.........
                        ? InterpolationModeDefault
                        : m_config.interpolationmode == RESIZE_LOW
                            ? InterpolationModeLowQuality
                            // m_config.interpolationmode == RESIZE_HIGHEST
                            : InterpolationModeHighQualityBicubic);

                if (m_dragging) bufgfx.SetInterpolationMode(InterpolationModeLowQuality);

                REAL srcWidth = m_bmpnew->GetWidth();
                REAL srcHeight = m_bmpnew->GetHeight();
                REAL srcX = 0;
                REAL srcY = 0;

                /*if (m_config.padding < 0)
                {
                    if(abs(m_config.padding) < m_bmpnew->GetWidth() &&
                       abs(m_config.padding) < m_bmpnew->GetHeight())
                    {
                        srcWidth+=2*m_config.padding;
                        srcHeight+=2*m_config.padding;
                        srcX-=m_config.padding;
                        srcY-=m_config.padding;
                    }
                }*/

                bufgfx.SetClip(wndrect);    // ensures that padding is respected
                bufgfx.DrawImage(
                    &(*m_bmpnew),
                    rect,         // destination rectangle
                    srcX, srcY,   // upper-left corner of source rectangle
                    srcWidth,     // width of source rectangle
                    srcHeight,    // height of source rectangle
                    UnitPixel);
            }

            // m_bufnew updated. time to fade in the changes.
            DWORD now = GetTickCount();
            if (m_config.animtime != 0 && !size_changed && (m_animshouldstart+700) > now)
            {
                m_animating = true;
                m_animstarted=GetTickCount();
                set_anim_timer();
            }
        }



        Rect dest(wndrect_temp.left,
            wndrect_temp.top,
            wndrect_temp.right-wndrect_temp.left,
            wndrect_temp.bottom-wndrect_temp.top);
        if (m_bufnew.is_valid() && !m_animating)
        {
            gfx.DrawImage(m_bufnew.get_ptr(), 0, 0);
        }
        else if (m_animating && m_bufnew.is_valid() && m_bufanim.is_valid())
        {
            float opacityold=0.0f;
            float opacitynew=1.0f;
            int doneness=GetTickCount();
            if (doneness > (m_animstarted+m_config.animtime))
            // animation complete
            {
                m_animating=false;
                opacityold=0.0f;
                opacitynew=1.0f;
            }
            else if (doneness >= m_animstarted && m_config.animtime != 0)
            {
                opacitynew=(float)(doneness-m_animstarted)/(float)m_config.animtime;
                opacityold=1.0f-0.0f;
            }
            {
                Graphics animbuf(m_bufanim.get_ptr());
                animbuf.Clear(bg);
                ColorMatrix cm;
                ZeroMemory(&cm,sizeof(ColorMatrix));
                cm.m[0][0] = 1.0f;
                cm.m[1][1] = 1.0f;
                cm.m[2][2] = 1.0f;
                cm.m[3][3] = opacityold;

                ImageAttributes ia;
                ia.SetColorMatrix(&cm);
                animbuf.DrawImage(m_bufold.get_ptr(),dest,0,0,dest.Width,dest.Height,UnitPixel,&ia);
                cm.m[3][3] = opacitynew;
                ia.SetColorMatrix(&cm);
                animbuf.DrawImage(m_bufnew.get_ptr(),dest,0,0,dest.Width,dest.Height,UnitPixel,&ia);
            }
            gfx.DrawImage(m_bufanim.get_ptr(), 0, 0);
            if (m_animating)
                set_anim_timer();
            else
                m_bufanim.release();
        }
        else gfx.Clear(bg);

        m_bmpnew.release();
    }
}
开发者ID:Duny,项目名称:foo_uie_albumart_mod,代码行数:101,代码来源:uie_albumart.cpp


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