mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +03:00
code style
This commit is contained in:
parent
37841dbaeb
commit
f8912a73e0
|
@ -75,7 +75,7 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
(UINT8*) im->image[state->y + state->yoff] +
|
(UINT8*) im->image[state->y + state->yoff] +
|
||||||
state->xoff * im->pixelsize, state->xsize);
|
state->xoff * im->pixelsize, state->xsize);
|
||||||
|
|
||||||
state->y++;
|
state->y += 1;
|
||||||
|
|
||||||
state->count = 1;
|
state->count = 1;
|
||||||
state->LAST = state->buffer[0];
|
state->LAST = state->buffer[0];
|
||||||
|
@ -103,22 +103,23 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
|
|
||||||
if (state->count == 63) {
|
if (state->count == 63) {
|
||||||
/* this run is full; flush it */
|
/* this run is full; flush it */
|
||||||
if (bytes < 2)
|
if (bytes < 2) {
|
||||||
return ptr - buf;
|
return ptr - buf;
|
||||||
*ptr++ = 0xff;
|
}
|
||||||
*ptr++ = state->LAST;
|
ptr[0] = 0xff;
|
||||||
|
ptr[1] = state->LAST;
|
||||||
|
ptr += 2;
|
||||||
bytes -= 2;
|
bytes -= 2;
|
||||||
|
|
||||||
state->count = 0;
|
state->count = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this = state->buffer[state->x];
|
this = state->buffer[state->x];
|
||||||
|
|
||||||
if (this == state->LAST) {
|
if (this == state->LAST) {
|
||||||
/* extend the current run */
|
/* extend the current run */
|
||||||
state->x++;
|
state->x += 1;
|
||||||
state->count++;
|
state->count += 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* start a new run */
|
/* start a new run */
|
||||||
|
@ -126,15 +127,17 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
if (bytes < 1) {
|
if (bytes < 1) {
|
||||||
return ptr - buf;
|
return ptr - buf;
|
||||||
}
|
}
|
||||||
*ptr++ = state->LAST;
|
ptr[0] = state->LAST;
|
||||||
bytes--;
|
ptr += 1;
|
||||||
|
bytes -= 1;
|
||||||
} else {
|
} else {
|
||||||
if (state->count > 0) {
|
if (state->count > 0) {
|
||||||
if (bytes < 2) {
|
if (bytes < 2) {
|
||||||
return ptr - buf;
|
return ptr - buf;
|
||||||
}
|
}
|
||||||
*ptr++ = 0xc0 | state->count;
|
ptr[0] = 0xc0 | state->count;
|
||||||
*ptr++ = state->LAST;
|
ptr[1] = state->LAST;
|
||||||
|
ptr += 2;
|
||||||
bytes -= 2;
|
bytes -= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,8 +145,7 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
state->LAST = this;
|
state->LAST = this;
|
||||||
state->count = 1;
|
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) {
|
if (bytes < 1 + padding) {
|
||||||
return ptr - buf;
|
return ptr - buf;
|
||||||
}
|
}
|
||||||
*ptr++ = state->LAST;
|
ptr[0] = state->LAST;
|
||||||
bytes--;
|
ptr += 1;
|
||||||
|
bytes -= 1;
|
||||||
} else {
|
} else {
|
||||||
if (state->count > 0) {
|
if (state->count > 0) {
|
||||||
if (bytes < 2 + padding) {
|
if (bytes < 2 + padding) {
|
||||||
return ptr - buf;
|
return ptr - buf;
|
||||||
}
|
}
|
||||||
*ptr++ = 0xc0 | state->count;
|
ptr[0] = 0xc0 | state->count;
|
||||||
*ptr++ = state->LAST;
|
ptr[1] = state->LAST;
|
||||||
|
ptr += 2;
|
||||||
bytes -= 2;
|
bytes -= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,15 +172,16 @@ ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
||||||
return ptr - buf;
|
return ptr - buf;
|
||||||
}
|
}
|
||||||
/* add the padding */
|
/* add the padding */
|
||||||
for (i=0;i<padding;i++){
|
for (i = 0; i < padding; i++) {
|
||||||
*ptr++=0;
|
ptr[0] = 0;
|
||||||
bytes--;
|
ptr += 1;
|
||||||
|
bytes -= 1;
|
||||||
}
|
}
|
||||||
/* reset for the next color plane. */
|
/* reset for the next color plane. */
|
||||||
if (state->x < planes * bytes_per_line) {
|
if (state->x < planes * bytes_per_line) {
|
||||||
state->count = 1;
|
state->count = 1;
|
||||||
state->LAST = state->buffer[state->x];
|
state->LAST = state->buffer[state->x];
|
||||||
state->x++;
|
state->x += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* read next line */
|
/* read next line */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user