Is it possible with PocketFrog to Blit, BlitRotate and BlitStretch only a mask of an image with a specified color?
Regards,
Kornalius
Regards,
Kornalius
A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.
struct MyShader : public PixelShader
{
Pixel operator() (Pixel src, Pixel dest) const
{
if(src == themask)
return ( color_as );
else
return ( dest );
}
};
MyShader myshader; // Creates a shader
themask = Imgs[1]->GetColorMask(); //get mask color
color_as = Color(255,0,0);
display->SetPixelShader(&myshader);
Imgs[1]->SetColorMask(-1); // turn off mask
display->Blit(50,50, Imgs[1]);
Imgs[1]->SetColorMask(themask); //set mask back to original
display->SetDefaultShader();
//added JLE 05/17/2004
void Raster2D::BlitMask( GraphicBuffer& buffer, const Rect& destRect, const GraphicBuffer& source
, const Rect& srcRect, Pixel colorMask, Pixel shade, unsigned char amount )
{
assert( destRect.GetWidth() == srcRect.GetWidth() );
assert( destRect.GetHeight() == srcRect.GetHeight() );
//todo: optimize
const Pixel* pSrc = source.GetPixels( srcRect.left, srcRect.top );
Pixel* pDest = buffer.GetPixels( destRect.left, destRect.top );
for ( int h = srcRect.GetHeight(); h; --h )
{
Pixel *dest = (pDest);
const Pixel *src = (pSrc);
for(int w = srcRect.GetWidth(); w ; --w)
{
if(*src != colorMask)
{
const unsigned long mask = RED_MASK | BLUE_MASK | (GREEN_MASK << 16);
unsigned long d = shade;
unsigned long s = *src;
//split into xGxRxB
d = (d | (d<<16)) & mask;
s = (s | (s<<16)) & mask;
//do alpha op
d = ((((d-s)*(amount>>3))>>5) + s)&mask;
//recombine into RGB
d |= d >> 16;
*dest = d;
}
dest++;
src++;
}
pDest += ((buffer.GetPitch())>>1);
pSrc += ((source.GetPitch())>>1);
}
}
struct MyShader2 : public PixelShader
{
int shade;
int amount;
void SetVals(int s, int a)
{ shade = s; amount = a; }
Pixel operator() (Pixel src, Pixel dest) const
{
const unsigned long mask = RED_MASK | BLUE_MASK | (GREEN_MASK << 16);
unsigned long d = shade;
unsigned long s = src;
//split into xGxRxB
d = (d | (d<<16)) & mask;
s = (s | (s<<16)) & mask;
//do alpha op
d = ((((d-s)*(amount>>3))>>5) + s)&mask;
//recombine into RGB
d |= d >> 16;
return (unsigned __int16)(d);
}
};