예제 #1
0
uint32_t  freetype2_setfontcolor(PFont pfont, uint32_t color)
{
	PFontFreetype pf = (PFontFreetype) pfont;
	uint32_t last_color;
	switch(pf->disp)
	{
		case DISPLAY_PIXEL_FORMAT_5551:
			last_color = MAKE_RGBA_5551(pf->r,pf->g,pf->b,pf->a);
			GET_RGBA_5551(color,pf->r,pf->g,pf->b,pf->a);
			break;
		case DISPLAY_PIXEL_FORMAT_4444:
			last_color = MAKE_RGBA_4444(pf->r,pf->g,pf->b,pf->a);
			GET_RGBA_4444(color,pf->r,pf->g,pf->b,pf->a);
			break;
		case DISPLAY_PIXEL_FORMAT_565:
			last_color = MAKE_RGBA_565(pf->r,pf->g,pf->b,pf->a);
			GET_RGBA_565(color,pf->r,pf->g,pf->b,pf->a);
			break;
//		case DISPLAY_PIXEL_FORMAT_8888:
	default:
			last_color = MAKE_RGBA_8888(pf->r,pf->g,pf->b,pf->a);
			GET_RGBA_8888(color,pf->r,pf->g,pf->b,pf->a);
			break;
	}
	freetype2_calcalphatable(pfont);
	return last_color;
}
예제 #2
0
void scale_col (uint8 *sdata, uint32 sw, uint8 *ddata, uint32 dw,uint32 dh, uint32 u, line_contrib_type *contrib,uint32 dpitch,uint32 dtype)
{ 
    uint32 y, i;
	uint8 r,g,b,a,sr,sb,sg,sa;
	uint32 left,right;
	uint32 *src32,*dst32;
	uint16 *src16,*dst16;
	src32 = (uint32*)sdata;
	dst32 = (uint32*)ddata;
	src16 = (uint16*)sdata;
	dst16 = (uint16*)ddata;

	for (y = 0; y < dh; y++) 
    {    // Loop through column
        left  = contrib->contrib_row[y].left;    // Retrieve left boundries
        right = contrib->contrib_row[y].right;  // Retrieve right boundries
		r = 0,g = 0,b = 0,a = 0;
        for (i = left; i <= right; i++)
        {   // Scan between boundries
            // Accumulate weighted effect of each neighboring pixel
			if(dtype == DISPLAY_PIXEL_FORMAT_8888){
				GET_RGBA_8888(src32[i * sw + u],sr,sg,sb,sa);
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_4444){ 
				GET_RGBA_4444(src16[i * sw + u],sr,sg,sb,sa);
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_5551){ 
				GET_RGBA_5551(src16[i * sw + u],sr,sg,sb,sa);
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_565){ 
				GET_RGBA_565(src16[i * sw + u],sr,sg,sb,sa);
			}

			if(sa==0)
				continue;
            r += (uint8)(contrib->contrib_row[y].weights[i-left] * (double)(sr)); 
            g += (uint8)(contrib->contrib_row[y].weights[i-left] * (double)(sg)); 
            b += (uint8)(contrib->contrib_row[y].weights[i-left] * (double)(sb));
			a += (uint8)(contrib->contrib_row[y].weights[i-left] * (double)(sa));
        }
		if(dtype == DISPLAY_PIXEL_FORMAT_8888)
			dst32[y*dpitch+u] = MAKE_RGBA_8888(r,g,b,a);   // Place result in destination pixel
		else if(dtype == DISPLAY_PIXEL_FORMAT_4444)
			dst16[y*dpitch+u] = MAKE_RGBA_4444(r,g,b,a);   // Place result in destination pixel
		else if(dtype == DISPLAY_PIXEL_FORMAT_5551)
			dst16[y*dpitch+u] = MAKE_RGBA_5551(r,g,b,a);   // Place result in destination pixel
		else if(dtype == DISPLAY_PIXEL_FORMAT_565)
			dst16[y*dpitch+u] = MAKE_RGBA_565(r,g,b,a);   // Place result in destination pixel
    }
} 
예제 #3
0
void scale_row (uint8 *sdata, uint32 sw,uint8 *ddata, uint32 dw, uint32 u, line_contrib_type *contrib,uint32 spitch,uint32 dtype)  
{
    uint32 x, i;
	uint32 *src32, *dst32;
	uint16 *src16, *dst16;
	uint8 sr, sg, sb, sa,r = 0,g = 0,b = 0,a = 0;
	src32 = (uint32*)sdata+u*spitch;
	dst32 = (uint32*)ddata+u*dw;
	src16 = (uint16*)sdata+u*spitch;
	dst16 = (uint16*)ddata+u*dw;
    for (x = 0; x < dw; x++) 
    {   // Loop through row
        int left  = contrib->contrib_row[x].left;    // Retrieve left boundries
        int right = contrib->contrib_row[x].right;  // Retrieve right boundries
		r = 0,g = 0,b = 0,a = 0;
        for (i = left; i <= right; i++)
        {   // Scan between boundries
            // Accumulate weighted effect of each neighboring pixel			
			if(dtype == DISPLAY_PIXEL_FORMAT_8888){
				GET_RGBA_8888(src32[i],sr,sg,sb,sa);
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_4444){
				GET_RGBA_4444(src16[i],sr,sg,sb,sa);
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_5551){
				GET_RGBA_5551(src16[i],sr,sg,sb,sa);
			}
			else{
				GET_RGBA_565(src16[i],sr,sg,sb,sa);
			}
				
			if(sa==0)
				continue;
			r += (uint8)(contrib->contrib_row[x].weights[i-left] * (double)(sr)); 
            g += (uint8)(contrib->contrib_row[x].weights[i-left] * (double)(sg)); 
            b += (uint8)(contrib->contrib_row[x].weights[i-left] * (double)(sb));
			a += (uint8)(contrib->contrib_row[x].weights[i-left] * (double)(sa));
        } 
        if(dtype == DISPLAY_PIXEL_FORMAT_8888)
			dst32[x] = MAKE_RGBA_8888(r,g,b,a); // Place result in destination pixel
		else if(dtype == DISPLAY_PIXEL_FORMAT_4444)
			dst16[x] = MAKE_RGBA_4444(r,g,b,a);
		else if(dtype == DISPLAY_PIXEL_FORMAT_5551)
			dst16[x] = MAKE_RGBA_5551(r,g,b,a);
		else if(dtype == DISPLAY_PIXEL_FORMAT_565)
			dst16[x] = MAKE_RGBA_565(r,g,b,a);
    } 
}
예제 #4
0
void JvCamera::draw(CCSprite* texture,float sx ,float sy ,float sw ,float sh ,float dx ,float dy ,
	float xscale ,float yscale ,float angle ,DRAWVH flag,int mask)
{
	int maskcolor = mask;
	
	CCSize winsize = CCSizeMake(JvG::width,JvG::height);
	float pixh =texture->getContentSize().height;
	texture->setPositionX(dx);
	texture->setPositionY(winsize.height - dy);
	float ty = pixh-sy - sh;
	texture->setTextureRect(CCRectMake(sx,ty,sw,sh));
	texture->setScaleX(xscale);
	texture->setScaleY(yscale);
	texture->setRotation(angle);
	if(maskcolor!=0)
	{
		int r,g,b,a;
		GET_RGBA_8888(maskcolor,r,g,b,a);
		texture->setColor(ccc3(r,g,b));
		texture->setOpacity(a);
	}
	switch(flag)
	{
	case NGE_FLIP_NONE:
		texture->setFlipX(false);
		texture->setFlipY(false);
		break;
	case NGE_FLIP_H:
		texture->setFlipX(true);
		break;
	case NGE_FLIP_V:
		texture->setFlipY(true);
		break;
	case NGE_FLIP_HV:
		texture->setFlipX(true);
		texture->setFlipY(true);
		break;
	default:
		break;
	}

	texture->visit();
}
예제 #5
0
void JvCamera::renderFlash()
{
	if (_flashDelay==0)
	{
		return;
	}

	_flashAlpha -= (int)((double)(JvG::elapsed/_flashDelay)*(double)255);
	int r,b,g,a;
	GET_RGBA_8888(_flashColor,r,g,b,a);
	if(_flashAlpha <= 0)
	{
		_flashAlpha = 0;
		_flashDelay = 0;
		return;
	}
	
	//flash
	_ccflashlayer->setColor(ccc3(r,g,b));
	_ccflashlayer->setOpacity(_flashAlpha);
	_ccflashlayer->visit();
}
예제 #6
0
//image conv
image_p image_conv(image_p src, int dtype)
{
	image_p dst;
	uint32_t i,j;
	uint32_t *src32, *dst32;
	uint16_t *src16, *dst16;
	uint8_t r,g,b,a;

	if(src->dtype == (uint32_t)dtype)
		return image_clone(src);

	CHECK_AND_UNSWIZZLE(src);
	dst = image_create(src->w, src->h, dtype);

	src32 = (uint32_t*)src->data;
	dst32 = (uint32_t*)dst->data;
	src16 = (uint16_t*)src->data;
	dst16 = (uint16_t*)dst->data;

	for(i = 0; i < src->h; i++)
	{
		for (j = 0; j<src->w; j++)
		{
			if(dtype == DISPLAY_PIXEL_FORMAT_8888){
				if(src->dtype == DISPLAY_PIXEL_FORMAT_4444){
					GET_RGBA_4444(src16[i*src->texw+j],r,g,b,a);
					dst32[i*dst->texw+j] = MAKE_RGBA_8888(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_5551){
					GET_RGBA_5551(src16[i*src->texw+j],r,g,b,a);
					dst32[i*dst->texw+j] = MAKE_RGBA_8888(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_565){
					GET_RGBA_565(src16[i*src->texw+j],r,g,b,a);
					dst32[i*dst->texw+j] = MAKE_RGBA_8888(r,g,b,a);
				}
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_4444){
				if(src->dtype == DISPLAY_PIXEL_FORMAT_8888){
					GET_RGBA_8888(src32[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_4444(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_5551){
					GET_RGBA_5551(src16[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_4444(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_565){
					GET_RGBA_565(src16[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_4444(r,g,b,a);
				}
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_5551){
				if(src->dtype == DISPLAY_PIXEL_FORMAT_8888){
					GET_RGBA_8888(src32[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_5551(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_4444){
					GET_RGBA_4444(src16[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_5551(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_565){
					GET_RGBA_565(src16[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_5551(r,g,b,a);
				}
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_565){
				if(src->dtype == DISPLAY_PIXEL_FORMAT_8888){
					GET_RGBA_8888(src32[i*src->texh+j],r,g,b,a);
					dst16[i*dst->texh+j] = MAKE_RGBA_565(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_4444){
					GET_RGBA_4444(src16[i*src->texh+j],r,g,b,a);
					dst16[i*dst->texh+j] = MAKE_RGBA_565(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_5551){
					GET_RGBA_5551(src16[i*src->texh+j],r,g,b,a);
					dst16[i*dst->texh+j] = MAKE_RGBA_565(r,g,b,a);
				}
			}
		}
	}
	dst->swizzle = 1;
	swizzle_swap(dst);
	CHECK_AND_SWIZZLE(src);
	return dst;
}
예제 #7
0
int get_saturation_brightness_color(int dtype, int scol,int saturation, int brightness)
{
	int r, g, b, a, mincol, maxcol;
	switch(dtype)
	{
	case DISPLAY_PIXEL_FORMAT_8888:
		GET_RGBA_8888(scol, r, g, b, a);
		break;
	case DISPLAY_PIXEL_FORMAT_4444:
		GET_RGBA_4444(scol, r, g, b, a);
		break;
	case DISPLAY_PIXEL_FORMAT_5551:
		GET_RGBA_5551(scol, r, g, b, a);
		break;
	case DISPLAY_PIXEL_FORMAT_565:
		GET_RGBA_565(scol, r, g, b, a);
		break;
	default:
		return 0;
	}
	// 处理饱和度
	if(saturation!=0)
	{
		maxcol = r>g ? (r>b?r:b):g;
		mincol = r>g ? (g>b?b:g):r;
		if(saturation>0)
		{
			if(maxcol == 0xff)
			{
				goto cont001;
			}
		}
		else
		{
			if(maxcol == 0)
			{
				goto cont001;
			}
		}
		r += mincol + (r - mincol)*(100 + saturation)/100;
		g = mincol + (g - mincol)*(100 + saturation)/100;
		b = mincol + (b - mincol)*(100 + saturation)/100;
		if(r>0xff)r=0xff;
		if(g>0xff)g=0xff;
		if(b>0xff)b=0xff;
		if(r<0)r=0;
		if(g<0)g=0;
		if(b<0)b=0;
	}
cont001:
	// 处理亮度
	if(brightness!=0)
	{
		//gcol = ((r + g + b) / 3) & 0xff;
		//maxcol = r>g ? (r>b?r:b):g;
		mincol = r>g ? (g>b?b:g):r;
		r += (0xff-mincol) * (brightness)/100;
		g += (0xff-mincol) * (brightness)/100;
		b += (0xff-mincol) * (brightness)/100;
		if(r>0xff)r=0xff;
		if(g>0xff)g=0xff;
		if(b>0xff)b=0xff;
		if(r<0)r=0;
		if(g<0)g=0;
		if(b<0)b=0;
	}

	// 输出
	switch(dtype)
	{
		case DISPLAY_PIXEL_FORMAT_8888:
			return MAKE_RGBA_8888(r, g, b, a);
			break;
		case DISPLAY_PIXEL_FORMAT_4444:
			return MAKE_RGBA_4444(r, g, b, a);
			break;
		case DISPLAY_PIXEL_FORMAT_5551:
			return MAKE_RGBA_5551(r, g, b, a);
			break;
		case DISPLAY_PIXEL_FORMAT_565:
			return MAKE_RGBA_565(r, g, b, a);
			break;
	}

	return 0;
}
예제 #8
0
int get_gray_color(int dtype, int scol, int gray)
{
	int gcol = 0, r = 0, g = 0, b = 0, a = 0;
	if(gray==0)
		return scol;
	switch(dtype)
	{
	case DISPLAY_PIXEL_FORMAT_8888:
		GET_RGBA_8888(scol, r, g, b, a);
		break;
	case DISPLAY_PIXEL_FORMAT_4444:
		GET_RGBA_4444(scol, r, g, b, a);
		break;
	case DISPLAY_PIXEL_FORMAT_5551:
		GET_RGBA_5551(scol, r, g, b, a);
		break;
	case DISPLAY_PIXEL_FORMAT_565:
		GET_RGBA_565(scol, r, g, b, a);
		break;
	}

	gcol = ((r + g + b) / 3) & 0xff;
	if(gray==100)
	{
		switch(dtype)
		{
			case DISPLAY_PIXEL_FORMAT_8888:
				return MAKE_RGBA_8888(gcol, gcol, gcol, a);
				break;
			case DISPLAY_PIXEL_FORMAT_4444:
				return MAKE_RGBA_4444(gcol, gcol, gcol, a);
				break;
			case DISPLAY_PIXEL_FORMAT_5551:
				return MAKE_RGBA_5551(gcol, gcol, gcol, a);
				break;
			case DISPLAY_PIXEL_FORMAT_565:
				return MAKE_RGBA_565(gcol, gcol, gcol, a);
				break;
		}
	}
	r += ((gcol - r) * gray / 100) & 0xff;
	g += ((gcol - g) * gray / 100) & 0xff;
	b += ((gcol - b) * gray / 100) & 0xff;

	switch(dtype)
	{
		case DISPLAY_PIXEL_FORMAT_8888:
			return MAKE_RGBA_8888(r, g, b, a);
			break;
		case DISPLAY_PIXEL_FORMAT_4444:
			return MAKE_RGBA_4444(r, g, b, a);
			break;
		case DISPLAY_PIXEL_FORMAT_5551:
			return MAKE_RGBA_5551(r, g, b, a);
			break;
		case DISPLAY_PIXEL_FORMAT_565:
			return MAKE_RGBA_565(r, g, b, a);
			break;
	}

	return 0;
}
예제 #9
0
image_p image_conv(image_p src, int dtype)
{
	image_p dst;
	uint8 recover = 0;
	uint32 i,j;
	uint32 *src32, *dst32;
	uint16 *src16, *dst16;
	uint8 r,g,b,a;

	if(src->dtype == dtype)
		return image_clone(src);

	if(src->swizzle ==1){
		unswizzle_swap(src);
		recover = 1;
	}
	dst = image_create(src->w, src->h, dtype);

	src32 = (uint32*)src->data;
	dst32 = (uint32*)dst->data;
	src16 = (uint16*)src->data;
	dst16 = (uint16*)dst->data;
	
	for(i = 0; i < src->h; i++)
	{
		for (j = 0; j<src->w; j++)
		{
			if(dtype == DISPLAY_PIXEL_FORMAT_8888){
				if(src->dtype == DISPLAY_PIXEL_FORMAT_4444){
					GET_RGBA_4444(src16[i*src->texw+j],r,g,b,a);
					dst32[i*dst->texw+j] = MAKE_RGBA_8888(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_5551){
					GET_RGBA_5551(src16[i*src->texw+j],r,g,b,a);
					dst32[i*dst->texw+j] = MAKE_RGBA_8888(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_565){
					GET_RGBA_565(src16[i*src->texw+j],r,g,b,a);
					dst32[i*dst->texw+j] = MAKE_RGBA_8888(r,g,b,a);
				}
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_4444){
				if(src->dtype == DISPLAY_PIXEL_FORMAT_8888){
					GET_RGBA_8888(src32[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_4444(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_5551){
					GET_RGBA_5551(src16[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_4444(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_565){
					GET_RGBA_565(src16[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_4444(r,g,b,a);
				}
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_5551){
				if(src->dtype == DISPLAY_PIXEL_FORMAT_8888){
					GET_RGBA_8888(src32[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_5551(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_4444){
					GET_RGBA_4444(src16[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_5551(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_565){
					GET_RGBA_565(src16[i*src->texw+j],r,g,b,a);
					dst16[i*dst->texw+j] = MAKE_RGBA_5551(r,g,b,a);
				}
			}
			else if(dtype == DISPLAY_PIXEL_FORMAT_565){
				if(src->dtype == DISPLAY_PIXEL_FORMAT_8888){
					GET_RGBA_8888(src32[i*src->texh+j],r,g,b,a);
					dst16[i*dst->texh+j] = MAKE_RGBA_565(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_4444){
					GET_RGBA_4444(src16[i*src->texh+j],r,g,b,a);
					dst16[i*dst->texh+j] = MAKE_RGBA_565(r,g,b,a);
				}
				else if(src->dtype == DISPLAY_PIXEL_FORMAT_5551){
					GET_RGBA_5551(src16[i*src->texh+j],r,g,b,a);
					dst16[i*dst->texh+j] = MAKE_RGBA_565(r,g,b,a);
				}
			}
		}
	}
	swizzle_swap(dst);
	if(recover)
		swizzle_swap(src);
	return dst;
}
예제 #10
0
image_p image_rot(image_p src,float angel)
{
	image_p dst;
	uint8 recover = 0;
	double sx,rs0,rs1,sy;
	double rangel;
	pointf d0,d1,d2,d3,d4;
	float x1,x2,y1,y2;
	sint16 xo, yo, wo, ho;
	uint32 i,j;
	uint32 *src32, *dst32;
	uint16 *src16, *dst16;
	uint16 r,g,b,a;
	uint16 r2,g2,b2,a2;
	uint8 smc;
	float xbx;

	while(angel > 360.0f)
		angel-=360.0f;

	while(angel<0)
		angel+=360.0f;

	if(angel == 0)
		return image_clone(src);
	
	if(src->swizzle ==1){
		unswizzle_swap(src);
		recover = 1;
	}

	rangel = angel*3.1415926f/180.0f;
	sx = cos(rangel);
	rs0 = sin(rangel);
	rs1 = -sin(rangel);
	sy = cos(rangel);

	d0.x = 0;
	d0.y = 0;
	d1 = image_rot_pointf(d0, sx, sy, rs0, rs1);
	d0.x = src->w;
	d2 = image_rot_pointf(d0, sx, sy, rs0, rs1);
	d0.y = src->h;
	d3 = image_rot_pointf(d0, sx, sy, rs0, rs1);
	d0.x = 0;
	d4 = image_rot_pointf(d0, sx, sy, rs0, rs1);

	x1 = min(d1.x, min(d2.x, min(d3.x, d4.x)));
	x2 = max(d1.x, max(d2.x, max(d3.x, d4.x)));
	y1 = min(d1.y, min(d2.y, min(d3.y, d4.y)));
	y2 = max(d1.y, max(d2.y, max(d3.y, d4.y)));

	xo = x1;
	yo = y1;
	wo = x2 - xo;
	ho = y2 - yo;

	dst = image_create(wo, ho, src->dtype);
	
	src32 = (uint32*)src->data;
	dst32 = (uint32*)dst->data;
	src16 = (uint16*)src->data;
	dst16 = (uint16*)dst->data;
	
	for(i = 0; i < dst->h; i++)
	{
		for (j = 0; j<dst->w; j++)
		{
			d0.x = j;
			d0.y = i;
			d0 = image_rot_pointf(d0, sx, sy, rs0, rs1);
			// easy way
			smc = 1;
			r2 = 0; g2 = 0; b2 = 0; a2 = 0;
			if(src->dtype == DISPLAY_PIXEL_FORMAT_8888){
				if((int)d0.y-yo < src->texh && (int)d0.x-xo < src->texw){
					//dst16[i*dst->texw+j] = src16[((int)d0.y-yo)*src->texw+(int)d0.x-xo];
					GET_RGBA_8888(src32[((int)d0.y-yo)*src->texw+(int)d0.x-xo], r, g, b, a);
					xbx = 1.0f - ((d0.y-yo) - (int)(d0.y-yo));
					r2 = r * xbx;
					g2 = g * xbx;
					b2 = b * xbx;
					a2 = a * xbx;

					if((int)d0.y-yo+1 < src->texh){
						smc++;
						xbx = 1.0f - xbx;
						GET_RGBA_8888(src32[((int)d0.y-yo+1)*src->texw+(int)d0.x-xo], r, g, b, a);
						r2 += r * xbx;
						g2 += g * xbx;
						b2 += b * xbx;
						a2 += a * xbx;
					}

					r = min(r2, 255);
					g = min(g2, 255);
					b = min(b2, 255);
					a = min(a2, 255);
					dst32[i*dst->texw+j] = MAKE_RGBA_8888(r,g,b,a);
				}
			}
			else if(src->dtype == DISPLAY_PIXEL_FORMAT_4444){
				if((int)d0.y-yo < src->texh && (int)d0.x-xo < src->texw){
					//dst16[i*dst->texw+j] = src16[((int)d0.y-yo)*src->texw+(int)d0.x-xo];
					GET_RGBA_4444(src16[((int)d0.y-yo)*src->texw+(int)d0.x-xo], r, g, b, a);
					xbx = 1.0f - ((d0.y-yo) - (int)(d0.y-yo));
					r2 = r * xbx;
					g2 = g * xbx;
					b2 = b * xbx;
					a2 = a * xbx;

					if((int)d0.y-yo+1 < src->texh){
						smc++;
						xbx = 1.0f - xbx;
						GET_RGBA_4444(src16[((int)d0.y-yo+1)*src->texw+(int)d0.x-xo], r, g, b, a);
						r2 += r * xbx;
						g2 += g * xbx;
						b2 += b * xbx;
						a2 += a * xbx;
					}

					r = min(r2, 255);
					g = min(g2, 255);
					b = min(b2, 255);
					a = min(a2, 255);
					dst16[i*dst->texw+j] = MAKE_RGBA_4444(r,g,b,a);
				}
			}
			else if(src->dtype == DISPLAY_PIXEL_FORMAT_5551){
				if((int)d0.y-yo < src->texh && (int)d0.x-xo < src->texw){
					//dst16[i*dst->texw+j] = src16[((int)d0.y-yo)*src->texw+(int)d0.x-xo];
					GET_RGBA_5551(src16[((int)d0.y-yo)*src->texw+(int)d0.x-xo], r, g, b, a);
					xbx = 1.0f - ((d0.y-yo) - (int)(d0.y-yo));
					r2 = r * xbx;
					g2 = g * xbx;
					b2 = b * xbx;
					a2 = a * xbx;

					if((int)d0.y-yo+1 < src->texh){
						smc++;
						xbx = 1.0f - xbx;
						GET_RGBA_5551(src16[((int)d0.y-yo+1)*src->texw+(int)d0.x-xo], r, g, b, a);
						r2 += r * xbx;
						g2 += g * xbx;
						b2 += b * xbx;
						a2 += a * xbx;
					}

					r = min(r2, 255);
					g = min(g2, 255);
					b = min(b2, 255);
					a = min(a2, 255);
					dst16[i*dst->texw+j] = MAKE_RGBA_5551(r,g,b,a);
				}
			}
			else{
				if((int)d0.y-yo < src->texh && (int)d0.x-xo < src->texw){
					//dst16[i*dst->texw+j] = src16[((int)d0.y-yo)*src->texw+(int)d0.x-xo];
					GET_RGBA_565(src16[((int)d0.y-yo)*src->texw+(int)d0.x-xo], r, g, b, a);
					xbx = 1.0f - ((d0.y-yo) - (int)(d0.y-yo));
					r2 = r * xbx;
					g2 = g * xbx;
					b2 = b * xbx;
					a2 = a * xbx;

					if((int)d0.y-yo+1 < src->texh){
						smc++;
						xbx = 1.0f - xbx;
						GET_RGBA_565(src16[((int)d0.y-yo+1)*src->texw+(int)d0.x-xo], r, g, b, a);
						r2 += r * xbx;
						g2 += g * xbx;
						b2 += b * xbx;
						a2 += a * xbx;
					}

					r = min(r2, 255);
					g = min(g2, 255);
					b = min(b2, 255);
					a = min(a2, 255);
					dst16[i*dst->texw+j] = MAKE_RGBA_565(r,g,b,a);
				}
			}
		}
	}
	
	swizzle_swap(dst);
	if(recover)
		swizzle_swap(src);
	return dst;
}