void BmpLoader::load_pixels_(Image::Data &data)
{
- data.pixels = new char[data.stride*data.height];
if(invert_row_order)
{
for(unsigned y=0; y<data.height; ++y)
ilBindImage(id);
unsigned data_size = data.stride*data.height;
- data.pixels = new char[data_size];
ILubyte *il_data = ilGetData();
copy(il_data, il_data+data_size, data.pixels);
fmt(RGB),
width(0),
height(0),
+ owned_pixels(0),
pixels(0)
{ }
width(other.width),
height(other.height),
stride(other.stride),
- pixels(other.pixels ? new char[stride*height] : 0)
+ owned_pixels(other.pixels ? new char[stride*height] : 0),
+ pixels(owned_pixels)
{
if(pixels)
copy(other.pixels, other.pixels+stride*height, pixels);
Image::Data &Image::Data::operator=(const Data &other)
{
- delete[] pixels;
- pixels = 0;
+ delete[] owned_pixels;
+ pixels = owned_pixels = 0;
fmt = other.fmt;
width = other.width;
if(other.pixels)
{
- pixels = new char[stride*height];
+ pixels = owned_pixels = new char[stride*height];
copy(other.pixels, other.pixels+stride*height, pixels);
}
Image::Data::~Data()
{
- delete[] pixels;
+ delete[] owned_pixels;
}
loader.load(data);
}
+void Image::load_into(ImageLoader &loader, void *buffer)
+{
+ data.pixels = reinterpret_cast<char *>(buffer);
+ load(loader);
+}
+
void Image::load_headers(ImageLoader &loader)
{
if(loader.get_state()==ImageLoader::INITIAL)
unsigned width;
unsigned height;
unsigned stride;
+ char *owned_pixels;
char *pixels;
Data();
void load_file(const std::string &);
void load_io(IO::Seekable &);
void load(ImageLoader &);
+ void load_into(ImageLoader &, void *);
void load_headers(ImageLoader &);
PixelFormat get_format() const { return data.fmt; }
if(state<HEADERS_LOADED)
load_headers_(data);
+ if(!data.pixels)
+ data.pixels = data.owned_pixels = new char[data.stride*data.height];
load_pixels_(data);
state = FINISHED;
}
void JpegLoader::load_pixels_(Image::Data &data)
{
- data.pixels = new char[data.stride*data.height];
JSAMPROW rows[8];
while(priv->jpeg.output_scanline<data.height)
{
throw bad_image_data(priv->message);
}
- data.pixels = new char[data.stride*data.height];
-
if(priv->interlace==PNG_INTERLACE_ADAM7)
{
// ADAM7 requires all rows to be loaded at once
{
CGDataProviderRef dp = CGImageGetDataProvider(image);
CFDataRef image_data = CGDataProviderCopyData(dp);
- data.pixels = new char[data.height*data.stride];
unsigned offset = (alpha==kCGImageAlphaNoneSkipFirst);
CFRange range = CFRangeMake(offset, CFDataGetLength(image_data)-offset);
CFDataGetBytes(image_data, range, reinterpret_cast<UInt8 *>(data.pixels));