- t = swf_InsertTag(t, ST_DEFINEBITSLOSSLESS);
-
- swf_SetU16(t, id); // id
-
- // Ah! The Flash specs says scanlines must be DWORD ALIGNED!
- // (but image width is the correct number of pixels)
- swf_width = BYTES_PER_SCANLINE(header.width);
-
- if ((imagedata = (U8 *)malloc(swf_width*header.height)) == NULL) {
- fprintf(stderr, "Failed to allocate memory required, aborted.");
- exit(2);
- }
- to = imagedata;
- from = (U8 *)gft->SavedImages[0].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)
- memcpy(to, from, header.width*header.height);
- 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) {
- 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 { // 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);
- }
- }
- }