 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mickey Guest
|
Posted: Tue May 23, 2006 5:21 pm Post subject: Blend Blit bug |
|
|
I have written a 16bit 565 50% blend blit for an embedded device but
it's got a bug I am having trouble with. I am trying to process two
pixels at once but the pixels seem to blit in a swapped order on the
device. Is there something wrong with this code or is it a device issue
where I would have to swap the pixels before blitting? In that case
would I be better offer processing a pixel at time?
uint8 *dst = dstBitData + ( dstY * dstPitch ) + ( dstX << 1 );
uint8 *src = srcBitData + ( srcY * srcPitch ) + ( srcX << 1 );
dstPad = dstPitch - ( dstWidth << 1 );
srcPad = srcPitch - ( dstWidth << 1 );
dstWidth >>= 1;
while( dstHeight-- )
{
register int32 col( dstWidth );
while( col-- )
{
*( reinterpret_cast<uint32*>( dst ) ) =
( ( *( reinterpret_cast<uint32*>( dst ) ) & RGB565_32_A128
) >> 1 ) + ( ( *( reinterpret_cast<uint32*>( src ) ) & RGB565_32_A128 )
src += 4;
}
dst += dstPad;
src += srcPad;
} |
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Tue May 23, 2006 5:21 pm Post subject: Re: Blend Blit bug |
|
|
Mickey wrote:
| Quote: | I have written a 16bit 565 50% blend blit for an embedded device but
it's got a bug I am having trouble with. I am trying to process two
pixels at once but the pixels seem to blit in a swapped order on the
device. Is there something wrong with this code
|
In what sense? Are we supposed to know that "blend blit" is?
| Quote: | or is it a device
issue where I would have to swap the pixels before blitting? In that
case would I be better offer processing a pixel at time?
uint8 *dst = dstBitData + ( dstY * dstPitch ) + ( dstX << 1 );
uint8 *src = srcBitData + ( srcY * srcPitch ) + ( srcX << 1 );
dstPad = dstPitch - ( dstWidth << 1 );
srcPad = srcPitch - ( dstWidth << 1 );
dstWidth >>= 1;
while( dstHeight-- )
{
register int32 col( dstWidth );
while( col-- )
{
*( reinterpret_cast<uint32*>( dst ) ) =
( ( *( reinterpret_cast<uint32*>( dst ) ) & RGB565_32_A128
) >> 1 ) + ( ( *( reinterpret_cast<uint32*>( src ) ) & RGB565_32_A128
)
1 );
dst += 4;
src += 4;
}
dst += dstPad;
src += srcPad;
}
|
The use of 'reinterpret_cast' is non-standard. Aside from that, your
code *probably* properly reflects your algorithm (whatever that is).
And if it doesn't do what you expect of it, it's either the algorithm
or your implementation of it, but they both are unknown here (lacking
your explanation of them).
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask |
|
| Back to top |
|
 |
Thomas J. Gritzan Guest
|
Posted: Tue May 23, 2006 7:21 pm Post subject: Re: Blend Blit bug |
|
|
Mickey schrieb:
| Quote: | I have written a 16bit 565 50% blend blit for an embedded device but
it's got a bug I am having trouble with. I am trying to process two
pixels at once but the pixels seem to blit in a swapped order on the
device. Is there something wrong with this code or is it a device issue
where I would have to swap the pixels before blitting? In that case
would I be better offer processing a pixel at time?
|
I think its not a C++ problem.
| Quote: | uint8 *dst = dstBitData + ( dstY * dstPitch ) + ( dstX << 1 );
uint8 *src = srcBitData + ( srcY * srcPitch ) + ( srcX << 1 );
dstPad = dstPitch - ( dstWidth << 1 );
srcPad = srcPitch - ( dstWidth << 1 );
dstWidth >>= 1;
while( dstHeight-- )
{
register int32 col( dstWidth );
while( col-- )
{
*( reinterpret_cast<uint32*>( dst ) ) =
( ( *( reinterpret_cast<uint32*>( dst ) ) & RGB565_32_A128 )
1 ) + ( ( *( reinterpret_cast<uint32*>( src ) ) & RGB565_32_A128 )
1 );
|
Google found this:
http://www.devolution.com/pipermail/sdl/2001-April/035108.html
/* blend two 16 bit pixels at 50% */
#define BLEND2x16_50(d, s, mask) \
(((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \
+ (s & d & (~(mask | mask << 16))))
Try to add the equivalent of the last line.
Thomas |
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group
|