Skip to content

Conversation

@brianpopow
Copy link
Collaborator

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

This is a follow up PR for #2172. It does a few things:

{
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];
Copy link
Member

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?

Copy link
Collaborator Author

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.                      |
--------------------------------------------------------------------------------

Copy link
Member

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.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants