]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/jpeg/jpegloader.cpp
Add some state checking to ImageLoader
[libs/gui.git] / source / graphics / jpeg / jpegloader.cpp
index 39866c18aaabaee7351f6fb2f419e8e3d4ab47ed..f61f651d5db13104c6ec6e54c397d5d10929d3fc 100644 (file)
@@ -113,13 +113,13 @@ JpegLoader::~JpegLoader()
 
 bool JpegLoader::detect(const string &sig)
 {
-       static const char jpeg_sig[] = "\xFF\xD8\xFF";
+       static const char jpeg_sig[] = { '\xFF', '\xD8', '\xFF' };
        if(sig.size()<sizeof(jpeg_sig))
                return false;
-       return !sig.compare(0, 3, jpeg_sig);
+       return !sig.compare(0, sizeof(jpeg_sig), jpeg_sig, sizeof(jpeg_sig));
 }
 
-void JpegLoader::load(Image::Data &data)
+void JpegLoader::load_(Image::Data &data)
 {
        if(setjmp(priv->err_mgr.jmp))
                throw bad_image_data(priv->err_mgr.message);
@@ -133,14 +133,14 @@ void JpegLoader::load(Image::Data &data)
        data.stride = priv->jpeg.output_width*priv->jpeg.output_components;
        data.fmt = RGB;
 
-       data.data = new char[data.stride*data.height];
+       data.pixels = new char[data.stride*data.height];
        JSAMPROW rows[8];
        while(priv->jpeg.output_scanline<data.height)
        {
                unsigned y = data.height-priv->jpeg.output_scanline;
                unsigned count = min(y, 8U);
                for(unsigned i=0; i<count; ++i)
-                       rows[i] = reinterpret_cast<JSAMPROW>(data.data+(y-i-1)*data.stride);
+                       rows[i] = reinterpret_cast<JSAMPROW>(data.pixels+(y-i-1)*data.stride);
                jpeg_read_scanlines(&priv->jpeg, rows, count);
        }