Previously, the order of data was incorrectly based on x_origin and
y_origin, which are meant for where on the screen the image should be
placed (TarGA is an image format meant for graphic cards), instead of
Image descriptor bits 4 and 5, which specify the direction.
This fixes a problem where tga files generated with magick would render
up-side-down.
The test images where created in GIMP, 4 simple 2x2 images
exported as .tga, no compression, origin: Bottom Left
square-bottom-left.tga:
Red, Green
Blue, Magenta
square-bottom-right.tga:
Green, Red
Magenta, Blue
square-top-left.tga:
Blue, Magenta
Red, Green
square-top-right.tga:
Magenta, Blue
Green, Red
then this script was ran:
```python
def update_tga_descriptor(file_path, top_to_bottom, left_to_right):
with open(file_path, 'r+b') as f:
header = f.read(18)
descriptor = header[17]
descriptor &= ~(1 << 4);
descriptor &= ~(1 << 5);
if left_to_right:
descriptor |= 1 << 4;
if top_to_bottom:
descriptor |= 1 << 5;
header = header[:17] + bytes([descriptor])
f.seek(0)
f.write(header)
update_tga_descriptor('square-bottom-left.tga', False, False)
update_tga_descriptor('square-bottom-right.tga', False, True)
update_tga_descriptor('square-top-left.tga', True, False)
update_tga_descriptor('square-top-right.tga', True, True)
```
This is for validating that a decoder with a weak or nonexistent
sniff() method thinks it can decode an image. This should not be
treated as an error.
No behavior change.
These methods are slightly more convenient than storing the Bytes
separately. However, it it feels unsanitary to reach in and access this
data directly. Both of the users of these already have the
[Readonly]Bytes available in their constructors, and can easily avoid
using these methods, so let's remove them entirely.
The conversion to AK::Stream makes everything much more straightforward
and understandable now, because we remove the custom reader we had.
Because AK::Stream is more tested, it means that the code should be now
more robust against bugs as well.
The ideal size is the size the user will display the image. Raster
formats should ignore this parameter, but vector formats can use
it to generate a bitmap of the ideal size.