* of the GNU Lesser General Public License.
*/
-#define LOCAL_DEBUG
+#undef LOCAL_DEBUG
#include "lib/lib.h"
#include "lib/mempool.h"
}
uns buf_size = file_size;
byte *buf = xmalloc(buf_size);
- bread(io->fastbuf, buf, buf_size);
+ breadb(io->fastbuf, buf, buf_size);
/* Allocate read structure */
struct magick_read_data *rd = io->read_data = mp_alloc(io->internal_pool, sizeof(*rd));
}
/* Fill image parameters */
- if (!io->cols)
- io->cols = rd->image->columns;
- if (!io->rows)
- io->rows = rd->image->rows;
- if (!(io->flags & IMAGE_CHANNELS_FORMAT))
+ io->cols = rd->image->columns;
+ io->rows = rd->image->rows;
+ switch (rd->image->colorspace)
{
- switch (rd->image->colorspace)
- {
- case GRAYColorspace:
- io->flags |= COLOR_SPACE_GRAYSCALE | IMAGE_ALPHA;
- break;
- default:
- io->flags |= COLOR_SPACE_RGB | IMAGE_ALPHA;
- break;
- }
+ case GRAYColorspace:
+ io->flags |= COLOR_SPACE_GRAYSCALE | IMAGE_ALPHA;
+ break;
+ default:
+ io->flags |= COLOR_SPACE_RGB | IMAGE_ALPHA;
+ break;
}
+ io->number_of_colors = rd->image->colors;
+ if (rd->image->storage_class == PseudoClass && rd->image->compression != JPEGCompression)
+ io->has_palette = 1;
io->read_cancel = libmagick_read_cancel;
return 1;
if (unlikely(!img2))
goto err2;
int result = image_scale(io->thread, img2, img);
- image_destroy(io->thread, img);
+ image_destroy(img);
img = img2;
need_destroy = !io->pool;
if (unlikely(!result))
libmagick_destroy_read_data(rd);
err2:
if (need_destroy)
- image_destroy(io->thread, img);
+ image_destroy(img);
return 0;
}
info = CloneImageInfo(NULL);
/* Setup image parameters and allocate the image*/
- switch (io->flags & IMAGE_COLOR_SPACE)
+ struct image *img = io->image;
+ switch (img->flags & IMAGE_COLOR_SPACE)
{
case COLOR_SPACE_GRAYSCALE:
info->colorspace = GRAYColorspace;
{
case IMAGE_FORMAT_JPEG:
strcpy(info->magick, "JPEG");
+ if (io->jpeg_quality)
+ info->quality = MIN(io->jpeg_quality, 100);
break;
case IMAGE_FORMAT_PNG:
strcpy(info->magick, "PNG");
image_thread_err(io->thread, IMAGE_ERR_WRITE_FAILED, "GraphicsMagick failed to allocate the image.");
goto err;
}
- image->columns = io->cols;
- image->rows = io->rows;
+ image->columns = img->cols;
+ image->rows = img->rows;
/* Get pixels */
- PixelPacket *pixels = SetImagePixels(image, 0, 0, io->cols, io->rows), *dest = pixels;
+ PixelPacket *pixels = SetImagePixels(image, 0, 0, img->cols, img->rows), *dest = pixels;
if (unlikely(!pixels))
{
image_thread_err(io->thread, IMAGE_ERR_WRITE_FAILED, "Cannot get GraphicsMagick pixels.");
}
/* Convert pixels */
- struct image *img = io->image;
switch (img->pixel_size)
{
case 1:
dest++; }while(0)
# include "images/image-walk.h"
break;
+
case 2:
# define IMAGE_WALK_INLINE
# define IMAGE_WALK_UNROLL 4
dest++; }while(0)
# include "images/image-walk.h"
break;
+
case 3:
# define IMAGE_WALK_INLINE
# define IMAGE_WALK_UNROLL 4
dest++; }while(0)
# include "images/image-walk.h"
break;
+
case 4:
# define IMAGE_WALK_INLINE
# define IMAGE_WALK_UNROLL 4
dest++; }while(0)
# include "images/image-walk.h"
break;
+
+ default:
+ ASSERT(0);
}
/* Store pixels */