-
-
Notifications
You must be signed in to change notification settings - Fork 888
TGA Encoder/Decoder Improvements #2197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… Packet otherwise
| { | ||
| var alpha = alphaBits == 0 ? byte.MaxValue : bufferSpan[idx + 3]; | ||
| color.FromBgra32(new Bgra32(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], (byte)alpha)); | ||
| byte alpha = alphaBits == 0 ? byte.MaxValue : bufferSpan[idx + 3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use Bgra here when the buffer is Rgba?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the Intel byte ordering, the data needs to be interpreted as bgra. Quote from the Spec:
| Image Data Field. |
| |
| This field specifies (width) x (height) pixels. Each |
| pixel specifies an RGB color value, which is stored as |
| an integral number of bytes. |
| The 2 byte entry is broken down as follows: |
| ARRRRRGG GGGBBBBB, where each letter represents a bit. |
| But, because of the lo-hi storage order, the first byte |
| coming from the file will actually be GGGBBBBB, and the |
| second will be ARRRRRGG. "A" represents an attribute bit. |
| The 3 byte entry contains 1 byte each of blue, green, |
| and red. |
| The 4 byte entry contains 1 byte each of blue, green, |
| red, and attribute. For faster speed (because of the |
| hardware of the Targa board itself), Targa 24 images are |
| sometimes stored as Targa 32 images. |
--------------------------------------------------------------------------------
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks... I was thrown by the assignment order in the Bgra32 constructor. Forgot the order was r,g,b,a.
JimBobSquarePants
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Prerequisites
Description
This is a follow up PR for #2172. It does a few things: