From f8912a73e07ba5f7821ca1d61284fc28f4c879fa Mon Sep 17 00:00:00 2001 From: homm Date: Wed, 27 Jul 2016 14:41:04 +0300 Subject: [PATCH] code style --- libImaging/PcxEncode.c | 47 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/libImaging/PcxEncode.c b/libImaging/PcxEncode.c index c73f49a24..b17a09184 100644 --- a/libImaging/PcxEncode.c +++ b/libImaging/PcxEncode.c @@ -75,7 +75,7 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) (UINT8*) im->image[state->y + state->yoff] + state->xoff * im->pixelsize, state->xsize); - state->y++; + state->y += 1; state->count = 1; state->LAST = state->buffer[0]; @@ -103,22 +103,23 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) if (state->count == 63) { /* this run is full; flush it */ - if (bytes < 2) + if (bytes < 2) { return ptr - buf; - *ptr++ = 0xff; - *ptr++ = state->LAST; + } + ptr[0] = 0xff; + ptr[1] = state->LAST; + ptr += 2; bytes -= 2; state->count = 0; - } this = state->buffer[state->x]; if (this == state->LAST) { /* extend the current run */ - state->x++; - state->count++; + state->x += 1; + state->count += 1; } else { /* start a new run */ @@ -126,15 +127,17 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) if (bytes < 1) { return ptr - buf; } - *ptr++ = state->LAST; - bytes--; + ptr[0] = state->LAST; + ptr += 1; + bytes -= 1; } else { if (state->count > 0) { if (bytes < 2) { return ptr - buf; } - *ptr++ = 0xc0 | state->count; - *ptr++ = state->LAST; + ptr[0] = 0xc0 | state->count; + ptr[1] = state->LAST; + ptr += 2; bytes -= 2; } } @@ -142,8 +145,7 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) state->LAST = this; state->count = 1; - state->x++; - + state->x += 1; } } @@ -152,15 +154,17 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) if (bytes < 1 + padding) { return ptr - buf; } - *ptr++ = state->LAST; - bytes--; + ptr[0] = state->LAST; + ptr += 1; + bytes -= 1; } else { if (state->count > 0) { if (bytes < 2 + padding) { return ptr - buf; } - *ptr++ = 0xc0 | state->count; - *ptr++ = state->LAST; + ptr[0] = 0xc0 | state->count; + ptr[1] = state->LAST; + ptr += 2; bytes -= 2; } } @@ -168,15 +172,16 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) return ptr - buf; } /* add the padding */ - for (i=0;ix < planes * bytes_per_line) { state->count = 1; state->LAST = state->buffer[state->x]; - state->x++; + state->x += 1; } } /* read next line */