Hi, in this code, the part starting at the line (comment) I've highlighted achieves the
same result as the second section of code, yet the offsets are 3, 2, and 1 for r, g and b in the first section and are 2, 1, 0 for the r, g and b in the section patch.
I got the second to work partly by using cout for debugging so I got it working. The problem is it doesn't make any sense to me why they both achieve the same thing. Can anyone help? me understand?
To be honest, I'm kind of surprised the first works at all.
Line 72 pulls an unsigned char into an int, and on 76 you're comparing it to the value 2044... But even though it's now an int, the highest value you could ever pull would be 255.
Also, I don't know if it'll help, but I always use "ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE" when locking my region. The documentation states
Like the version without _LE, but the component order is guaranteed to be red, green, blue, alpha. This only makes a difference on big endian systems, on little endian it is just an alias
Though I not sure what actually happens when using ALLEGRO_PIXEL_FORMAT_ABGR_8888 or ALLEGRO_PIXEL_FORMAT_ARGB_8888?
Thanks for your reply.
That 2044 should have been 204.
I had to edit the code of the first section and made a mistake.
I'd be interested to know your results... In fact, you don't post your pixel format for the second section. Maybe you accidently selected a different format on your calls?
Thanks again.
I didn't post the pixel format for section either.
I presume by "I'd like to see your results." you want me to try with some of those
pixel formats you suggested. I'm happy to do so. Do I need to use one of the al_set….() functions?
Line 59: ALLEGRO_PIXEL_FORMAT_RGBA_8888
It's up to you if you want to test, but it wouldn't surprise me if you were using a different format to lock the region for the second section
I think it's worth a try to set them all to ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE
Thanks. I realised what I did. I put ALLEGRO_LOCK_READWRITE for the pixel format when
I locked it in the code that calls the second section.
I've fixed that and put ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE for the pixel format for both of them and now the two ways of doing it do different things. Neither of them come out
how I need.
Is there a way to infer from ABGR what (ptr + 0), (ptr + 1), (ptr + 2), (ptr + 3)
point to. Is it the alpha component, the blue component, the green component and the red component in that order, as would seem intuitive?
This is what I use, and never have a problem
Thanks very much for the help.
It's working now and I understand it better.
Good stuff. You're welcome