Re: [dev] Looking for simple, alpha supporting image format

From: koneu <koneu93_AT_googlemail.com>
Date: Wed, 16 Jul 2014 16:10:56 +0200

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:10:56 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 16 2014 - 16:12:25 CEST