Blend Blit bug

M

Mickey

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 ) ) =
dst += 4;
src += 4;
}

dst += dstPad;
src += srcPad;
}
 
V

Victor Bazarov

Mickey said:
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?
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

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
 
T

Thomas J. Gritzan

Mickey said:
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.
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-- )
{

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,823
Latest member
Nadia88

Latest Threads

Top