Re: [dev] Looking for simple, alpha supporting image format
I'm with koneu on this one- why make it human readable?
I don't think you need to store the height either- just the width.
Then just read until EOF and the height will be implicit.
Honestly I'm surprised the header is just not [width] and nothing
else. Sure, if the file ever gets lost in deletion space it'll never
be recoverable, but that'll teach people not to remove files with so
much haste :)
On Wed, Jul 16, 2014 at 10:10 AM, koneu <koneu93_AT_googlemail.com> wrote:
> On July 16, 2014 4:09:03 PM CEST, Markus Teich <markus.teich_AT_stusta.mhn.de> wrote:
>>koneu wrote:
>>> On July 16, 2014 3:28:44 PM CEST, Markus Teich
>><markus.teich_AT_stusta.mhn.de> wrote:
>>> > *w = ntohs(hdr[9]);
>>> > *h = ntohs(hdr[11]);
>>>
>>> This will pass a char to ntohs; expanding it to a uint16_t, instead
>>of passing
>>> ntohs two bytes from the header.
>>
>>Heyho,
>>
>>of course you are right.
>>
>>ntohs(hdr[9] << 8 | hdr[10])
>>
>>or
>>
>>uint16_t *tw = hdr+9;
>>*w = ntohs(*tw);
>>
>>should work.
>>
>>> The proper way would involve some pointer casting or a header struct.
>>
>>With a struct you get alignment issues, especially with the 9 byte
>>magic, which
>>aligns to nothing but 1 byte boundaries.
>>
>>--Markus
>
> Nasty compiler screwing all my beautiful thoughts! :D
>
Received on Wed Jul 16 2014 - 16:16:17 CEST
This archive was generated by hypermail 2.3.0
: Wed Jul 16 2014 - 16:24:11 CEST