C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Blend Blit bug

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Mickey
Guest





PostPosted: Tue May 23, 2006 5:21 pm    Post subject: Blend Blit bug Reply with 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?

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 )
Quote:
1 );
dst += 4;

src += 4;
}

dst += dstPad;
src += srcPad;
}
Back to top
Victor Bazarov
Guest





PostPosted: Tue May 23, 2006 5:21 pm    Post subject: Re: Blend Blit bug Reply with quote



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





PostPosted: Tue May 23, 2006 7:21 pm    Post subject: Re: Blend Blit bug Reply with quote



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
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
 


Powered by phpBB © 2001, 2006 phpBB Group