Blitting (again!)

Hi All!

I was just wondering if there was a blitting function to just blit those
channels that you want to, IE just the red channel and have the other
channels being transparent. I’ve had a look through the source but can’t
find anything like I’m on about.

I did notice this though in SDL_blit.h:

#define FORMAT_EQUAL(A, B)
(((A)->BitsPerPixel == (B)->BitsPerPixel) && ((A)->Rmask ==
(B)->Rmask))

Now maybe I’m wrong, but isn’t the 16BPP a bit dodgy when it comes to
masks? I mean, I’ve seen at least 3 different versions, one where G = 5
bits, another where G = 6 bits, another where bit 16 = intensity. Surely
this will fail for 16BPP modes under circumstances right?

And no, I’m not calling you shirley :slight_smile:

-Lea.

Hi All!

I was just wondering if there was a blitting function to just blit those
channels that you want to, IE just the red channel and have the other
channels being transparent.

Nope, you’ll have to write your own.

I did notice this though in SDL_blit.h:

#define FORMAT_EQUAL(A, B)
(((A)->BitsPerPixel == (B)->BitsPerPixel) && ((A)->Rmask ==
(B)->Rmask))

Now maybe I’m wrong, but isn’t the 16BPP a bit dodgy when it comes to
masks? I mean, I’ve seen at least 3 different versions, one where G = 5
bits, another where G = 6 bits, another where bit 16 = intensity. Surely
this will fail for 16BPP modes under circumstances right?

That’s correct. It is supposed to fail unless the two modes are exactly
the same. 16bpp != 16bpp sometimes. :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Sam Lantinga wrote:

Nope, you’ll have to write your own.

Cool!

That’s correct. It is supposed to fail unless the two modes are exactly
the same. 16bpp != 16bpp sometimes. :slight_smile:

Hmmm… I think my point was that perhaps checking all the colour masks would
be in order for it to work correctly.
Or am I missing something obvious here? Wont this routine return true if 5,5,5
RGB and 5,6,5 RGB are compared?

-Lea.

Hmmm… I think my point was that perhaps checking all the colour masks would
be in order for it to work correctly.
Or am I missing something obvious here? Wont this routine return true if 5,5,5
RGB and 5,6,5 RGB are compared?

The 555 red mask is 0x7c00
The 565 red mask is 0xf800

Heh. True, there are a few possible combinations which would break, like
RGB555 and ARGB1555, but all the real-world combinations should work fine.
The motivation for the shortcut is of course, speed.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec

Doh! I should have thought about this for an extra 5 seconds.

Sam Lantinga wrote:> The 555 red mask is 0x7c00

The 565 red mask is 0xf800

Heh. True, there are a few possible combinations which would break, like
RGB555 and ARGB1555, but all the real-world combinations should work fine.
The motivation for the shortcut is of course, speed.