Skip to content

Commit

Permalink
found a way to merge these 4 cases into 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pkrumins committed Aug 7, 2010
1 parent 3a88d34 commit c962843
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions src/dynamic_gif_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,38 +84,6 @@ DynamicGifStack::GifEncode()

switch (buf_type) {
case BUF_RGB:
for (GifUpdates::iterator it = gif_stack.begin(); it != gif_stack.end(); ++it) {
GifUpdate *gif = *it;
int start = (gif->y - top.y)*width*3 + (gif->x - top.x)*3;
unsigned char *gifdatap = gif->data;
for (int i = 0; i < gif->h; i++) {
unsigned char *datap = &data[start + i*width*3];
for (int j = 0; j < gif->w; j++) {
*datap++ = *gifdatap++;
*datap++ = *gifdatap++;
*datap++ = *gifdatap++;
}
}
}
break;

case BUF_BGR:
for (GifUpdates::iterator it = gif_stack.begin(); it != gif_stack.end(); ++it) {
GifUpdate *gif = *it;
int start = (gif->y - top.y)*width*3 + (gif->x - top.x)*3;
unsigned char *gifdatap = gif->data;
for (int i = 0; i < gif->h; i++) {
unsigned char *datap = &data[start + i*width*3];
for (int j = 0; j < gif->w; j++) {
*datap++ = *(gifdatap + 2);
*datap++ = *(gifdatap + 1);
*datap++ = *gifdatap;
gifdatap += 3;
}
}
}
break;

case BUF_RGBA:
for (GifUpdates::iterator it = gif_stack.begin(); it != gif_stack.end(); ++it) {
GifUpdate *gif = *it;
Expand All @@ -127,12 +95,13 @@ DynamicGifStack::GifEncode()
*datap++ = *gifdatap++;
*datap++ = *gifdatap++;
*datap++ = *gifdatap++;
gifdatap++;
if (buf_type == BUF_RGBA) gifdatap++;
}
}
}
break;

case BUF_BGR:
case BUF_BGRA:
for (GifUpdates::iterator it = gif_stack.begin(); it != gif_stack.end(); ++it) {
GifUpdate *gif = *it;
Expand All @@ -144,7 +113,7 @@ DynamicGifStack::GifEncode()
*datap++ = *(gifdatap + 2);
*datap++ = *(gifdatap + 1);
*datap++ = *gifdatap;
gifdatap += 4;
gifdatap += (buf_type == BUF_BGRA) ? 4 : 3;
}
}
}
Expand Down

0 comments on commit c962843

Please sign in to comment.