]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/quartz/quartzloader.cpp
Allow images to have padding between rows
[libs/gui.git] / source / graphics / quartz / quartzloader.cpp
index 23f7abbed319031ff0e3b23f99b096bf9159174d..a7c610d4ab62094fa88c8969ea8bdb5fe6e76cdf 100644 (file)
@@ -93,6 +93,7 @@ void QuartzLoader::load(Image::Data &data)
        {
                data.width = CGImageGetWidth(image);
                data.height = CGImageGetHeight(image);
+               data.stride = CGImageGetBytesPerRow(image);
 
                CGColorSpaceRef color = CGImageGetColorSpace(image);
                CGColorSpaceModel model = CGColorSpaceGetModel(color);
@@ -109,11 +110,9 @@ void QuartzLoader::load(Image::Data &data)
                else
                        throw unsupported_image_format("unknown colorspace");
 
-               unsigned bytes_per_pixel = (CGImageGetBitsPerPixel(image)+7)/8;
-
                CGDataProviderRef dp = CGImageGetDataProvider(image);
                CFDataRef image_data = CGDataProviderCopyData(dp);
-               data.data = new char[data.width*data.height*bytes_per_pixel];
+               data.data = new char[data.height*data.stride];
                CFDataGetBytes(image_data, CFRangeMake(0, CFDataGetLength(image_data)), reinterpret_cast<UInt8 *>(data.data));
                CFRelease(image_data);