+ to = imagedata;
+ from = (U8 *)gft->SavedImages[imgidx].RasterBits;
+
+ if (swf_width == header.width) {
+ // we are all nicely aligned and don't need to move the bitmap around.
+ // Just copy the bits into the image buffer.
+ if (! gft->Image.Interlace)
+ if (header.width == img->Width && header.height == img->Height)
+ memcpy(to, from, header.width*header.height);
+ else { //small screen
+ for (i = 0; i < header.height; i++, to += header.width) {
+ memset(to, bgcolor, header.width);
+ if (i >= img->Top && i < img->Top + img->Height) {
+ memcpy(to + img->Left, from, img->Width);
+ from += img->Width;
+ }
+ }
+ }
+
+ else // Need to perform 4 passes on the interlaced images
+ for (i = 0; i < 4; i++)
+ for (j = interlacedOffset[i]; j < header.height;
+ j += interlacedJumps[i], from += header.width)
+ memcpy(to + header.width*j, from, header.width);
+ } else {
+ padlen = swf_width - header.width;
+
+ // here we need to pad the scanline
+ if (! gft->Image.Interlace) {
+ if (header.width == img->Width &&
+ header.height == img->Height) {
+ for (i=0; i < header.height; i++, from+=header.width, to+=swf_width) {
+ memcpy(to, from, header.width);
+ memset(to + header.width, bgcolor, padlen);
+ }
+ } else { //small screen
+ for (i=0; i < header.height; i++, to += swf_width) {
+ memset(to, bgcolor, swf_width);
+ if (i >= img->Top && i < img->Top + img->Height) {
+ memcpy(to + img->Left, from, img->Width);
+ from += img->Width;
+ }
+ }
+ }
+ } else { // Need to perform 4 passes on the interlaced images
+ for (i = 0; i < 4; i++)
+ for (j = interlacedOffset[i]; j < header.height;
+ j += interlacedJumps[i], from += header.width) {
+ memcpy(to + swf_width*j, from, header.width);
+ memset(to + swf_width*j, bgcolor, padlen);
+ }
+ }
+ }