// For reading SWF JPEG3-style image data, like ordinary JPEG, // but stores the data in ImageRGBA format. std::unique_ptr<ImageRGBA> Input::readSWFJpeg3(std::shared_ptr<IOChannel> in) { std::unique_ptr<ImageRGBA> im; // Calling with headerBytes as 0 has a special effect... std::unique_ptr<JpegInput> j_in( JpegInput::createSWFJpeg2HeaderOnly(in, 0)); // If this isn't true, we should have thrown. assert(j_in.get()); j_in->read(); const size_t height = j_in->getHeight(); const size_t width = j_in->getWidth(); im.reset(new ImageRGBA(width, height)); if (j_in->imageType() == TYPE_RGBA) { for (size_t y = 0; y < height; ++y) { j_in->readScanline(scanline(*im, y)); } } else { std::unique_ptr<GnashImage::value_type[]> line( new GnashImage::value_type[3 * width]); for (size_t y = 0; y < height; ++y) { j_in->readScanline(line.get()); GnashImage::iterator data = scanline(*im, y); for (size_t x = 0; x < width; ++x) { data[4*x+0] = line[3*x+0]; data[4*x+1] = line[3*x+1]; data[4*x+2] = line[3*x+2]; data[4*x+3] = 255; } } } return im; }
// For reading SWF JPEG3-style image data, like ordinary JPEG, // but stores the data in ImageRGBA format. std::auto_ptr<ImageRGBA> ImageInput::readSWFJpeg3(boost::shared_ptr<IOChannel> in) { std::auto_ptr<ImageRGBA> im; // Calling with headerBytes as 0 has a special effect... std::auto_ptr<JpegImageInput> j_in( JpegImageInput::createSWFJpeg2HeaderOnly(in, 0)); // If this isn't true, we should have thrown. assert(j_in.get()); j_in->read(); const size_t height = j_in->getHeight(); const size_t width = j_in->getWidth(); im.reset(new ImageRGBA(width, height)); boost::scoped_array<boost::uint8_t> line(new boost::uint8_t[3 * width]); for (size_t y = 0; y < height; ++y) { j_in->readScanline(line.get()); boost::uint8_t* data = im->scanline(y); for (size_t x = 0; x < width; ++x) { data[4*x+0] = line[3*x+0]; data[4*x+1] = line[3*x+1]; data[4*x+2] = line[3*x+2]; data[4*x+3] = 255; } } return im; }