Ejemplo n.º 1
0
Bitmap* PixmanBitmap::Resample(int scale_w, int scale_h, const Rect& src_rect) {
	PixmanBitmap *dst = new PixmanBitmap(scale_w, scale_h, GetTransparent());

	double zoom_x = (double)src_rect.width  / scale_w;
	double zoom_y = (double)src_rect.height / scale_h;

	pixman_transform_t xform;
	pixman_transform_init_scale(&xform,
								pixman_double_to_fixed(zoom_x),
								pixman_double_to_fixed(zoom_y));
	
	pixman_image_set_transform(bitmap, &xform);

	pixman_image_composite32(PIXMAN_OP_SRC,
							 bitmap, (pixman_image_t*) NULL, dst->bitmap,
							 src_rect.x, src_rect.y,
							 0, 0,
							 0, 0,
							 scale_w, scale_h);

	pixman_transform_init_identity(&xform);
	pixman_image_set_transform(bitmap, &xform);

	return dst;
}
Ejemplo n.º 2
0
void gdImage::Copy(gdImage& dst, int dstX, int dstY, int srcX, int srcY, int w, int h)
{
	int c;
	int x, y;
	int tox, toy;
	int i;
	int colorMap[gdMaxColors];
	for (i=0; (i<gdMaxColors); i++) {
		colorMap[i] = (-1);
	}
	toy = dstY;
	for (y=srcY; (y < (srcY + h)); y++) {
		tox = dstX;
		for (x=srcX; (x < (srcX + w)); x++) {
			int nc;
			c = GetPixel(x, y);
			/* Added 7/24/95: support transparent copies */
			if (GetTransparent() == c) {
				tox++;
				continue;
			}
			/* Have we established a mapping for this color? */
			if (colorMap[c] == (-1)) {
				/* If it's the same image, mapping is trivial */
				if (&dst == this) {
					nc = c;
				} else { 
					/* First look for an exact match */
					nc = dst.ColorExact(
						red[c], green[c],
						blue[c]);
				}	
				if (nc == (-1)) {
					/* No, so try to allocate it */
					nc = dst.ColorAllocate(
						red[c], green[c],
						blue[c]);
					/* If we're out of colors, go for the
						closest color */
					if (nc == (-1)) {
						nc = dst.ColorClosest(
							red[c], green[c],
							blue[c]);
					}
				}
				colorMap[c] = nc;
			}
			dst.SetPixel(tox, toy, colorMap[c]);
			tox++;
		}
		toy++;
	}
}			
Ejemplo n.º 3
0
void SQRCheckButton::DrawWndBackground()
{
	m_beBGDrawed = true;
	//处于选中状态
	if( m_bCheck )
		DrawBackImage( m_hWnd->m_Enable, m_hWnd->m_Disable, m_MouseOverImage, m_ClickDownImage, IsHeld() );
	else
	{
		CFPos pt = GetCursorPos();
		if( IsHeld() )
		{
			SetEventStateMask(IP_UNCHECK_CLICKDOWN);
			DrawRect( m_UncheckClickDownImage );
		}
		else if( IsInWndArea( pt.x, pt.y ) && IsEnable() && IsLastMouseMsgWnd() )
		{
			SetEventStateMask(IP_UNCHECK_MOUSEOVER);
			DrawRect( m_UncheckMouseOverImage );
		}
		else if( !IsEnable() )
		{
			SetEventStateMask(IP_UNCHECK_DISABLE);
			DrawRect( m_UncheckDisableImage );
		}
		else if( m_uFlashCircle && m_uFlashEndTime - m_uFlashStartTime > uint32(GetProcessTime()) - m_uFlashStartTime )
		{
			float fAlpha  = GetTransparent();
			float fWeight = abs( (float)( ( uint32(GetProcessTime()) - m_uFlashStartTime )%( m_uFlashCircle*2 ) - m_uFlashCircle ) )/m_uFlashCircle;
			SetTransparent( fAlpha*fWeight );
			SetEventStateMask(IP_UNCHECK_ENABLE);
			DrawRect( m_UncheckEnableImage );
			SetTransparent( fAlpha*( 1.0f - fWeight ) );
			SetEventStateMask(IP_UNCHECK_MOUSEOVER);
			DrawRect( m_UncheckMouseOverImage );
			SetTransparent( fAlpha );
		}
		else
		{
			SetEventStateMask(IP_UNCHECK_ENABLE);
			DrawRect( m_UncheckEnableImage );
		}
	}
}
Ejemplo n.º 4
0
void PixmanBitmap::Flip(const Rect& dst_rect, bool horizontal, bool vertical) {
	if (!horizontal && !vertical)
		return;

	PixmanBitmap* resampled = new PixmanBitmap(dst_rect.width, dst_rect.height, GetTransparent());

	resampled->FlipBlit(0, 0, this, dst_rect, horizontal, vertical);

	pixman_image_composite32(PIXMAN_OP_SRC,
							 resampled->bitmap, (pixman_image_t*) NULL, bitmap,
							 0, 0,
							 0, 0,
							 dst_rect.x, dst_rect.y,
							 dst_rect.width, dst_rect.height);

	delete resampled;

	RefreshCallback();
}
Ejemplo n.º 5
0
void SQRButton::DrawBackImage( WND_IMAGE_LIST& Enable, WND_IMAGE_LIST& Disable, WND_IMAGE_LIST& MouseOver, WND_IMAGE_LIST& ClickDown, bool bClick )
{
	if(!Enable.IsImageLoadValid()&&!Disable.IsImageLoadValid())
		return;
	CFPos pt = GetCursorPos();
	if( bClick )
	{
		SetEventStateMask(IP_CLICKDOWN);
		DrawRect( ClickDown );
	}
	else if( IsInWndArea( pt.x, pt.y ) && IsEnable() && IsLastMouseMsgWnd() )
	{
		SetEventStateMask(IP_MOUSEOVER);
		DrawRect( MouseOver );
	}
	else if( !IsEnable() )
	{
		SetEventStateMask(IP_DISABLE);
		DrawRect( Disable );
	}
	else if( m_uFlashCircle && m_uFlashEndTime - m_uFlashStartTime > uint32(GetProcessTime()) - m_uFlashStartTime )
	{
		float fAlpha  = GetTransparent();
		float fWeight = abs( (float)( ( uint32(GetProcessTime()) - m_uFlashStartTime )%( m_uFlashCircle*2 ) - m_uFlashCircle ) )/m_uFlashCircle;
		SetTransparent( fAlpha*fWeight );
		SetEventStateMask(IP_ENABLE);
		DrawRect( Enable );
		SetTransparent( fAlpha*( 1.0f - fWeight ) );
		DrawRect( MouseOver );
		SetTransparent( fAlpha );
	}
	else
	{
		SetEventStateMask(IP_ENABLE);
		DrawRect( Enable );
	}

	if( m_bFirstMouseOver && GetEventStateMask() == IP_MOUSEOVER )
		OnPlayWndSound( eMS_MouseOver );

	m_bFirstMouseOver = GetEventStateMask() == IP_MOUSEOVER ? false : true;
}
Ejemplo n.º 6
0
void PixmanBitmap::ToneBlit(int x, int y, Bitmap* _src, Rect src_rect, const Tone &tone) {
	if (tone == Tone()) {
		if (_src != this)
			Blit(x, y, _src, src_rect, 255);
		return;
	}

	PixmanBitmap* src = (PixmanBitmap*) _src;

	if (_src != this)
		pixman_image_composite32(PIXMAN_OP_SRC,
								 src->bitmap, (pixman_image_t*) NULL, bitmap,
								 src_rect.x, src_rect.y,
								 0, 0,
								 x, y,
								 src_rect.width, src_rect.height);

	if (tone.gray == 0) {
		pixman_color_t tcolor = {tone.red << 8, tone.green << 8, tone.blue << 8, 0xFFFF};
		pixman_image_t *timage = pixman_image_create_solid_fill(&tcolor);

		pixman_image_composite32(PIXMAN_OP_ADD,
								 timage, src->bitmap, bitmap,
								 src_rect.x, src_rect.y,
								 0, 0,
								 x, y,
								 src_rect.width, src_rect.height);

		pixman_image_unref(timage);
	}
	else {
		pixman_rectangle16_t rect = {0, 0, src_rect.width, src_rect.height};

		PixmanBitmap *gray = new PixmanBitmap(src, src_rect, GetTransparent());
		pixman_color_t gcolor = {0, 0, 0, 0xFFFF};
		pixman_image_fill_rectangles(PIXMAN_OP_HSL_SATURATION, gray->bitmap, &gcolor, 1, &rect);

		pixman_color_t acolor = {0, 0, 0, tone.gray << 8};
		pixman_image_fill_rectangles(PIXMAN_OP_IN_REVERSE, gray->bitmap, &acolor, 1, &rect);

		pixman_image_composite32(PIXMAN_OP_ATOP,
								 gray->bitmap, (pixman_image_t*) NULL, bitmap,
								 src_rect.x, src_rect.y,
								 0, 0,
								 x, y,
								 src_rect.width, src_rect.height);

		pixman_color_t tcolor = {tone.red << 8, tone.green << 8, tone.blue << 8, 0xFFFF};
		pixman_image_t *timage = pixman_image_create_solid_fill(&tcolor);

		pixman_image_composite32(PIXMAN_OP_ADD,
								 timage, src->bitmap, bitmap,
								 src_rect.x, src_rect.y,
								 0, 0,
								 x, y,
								 src_rect.width, src_rect.height);

		pixman_image_unref(timage);

		delete gray;
	}

	RefreshCallback();
}