mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Fix a crash when performing some image editing operations on 64 bit calibre builds
This commit is contained in:
parent
bd460282a5
commit
856db1901b
@ -14,7 +14,6 @@ from PyQt4.Qt import (
|
||||
QPointF, QPen, pyqtSignal, QUndoCommand, QUndoStack, QIcon, QImage, QByteArray)
|
||||
|
||||
from calibre import fit_image
|
||||
from calibre.constants import isosx
|
||||
from calibre.gui2 import error_dialog, pixmap_to_data
|
||||
from calibre.gui2.dnd import (
|
||||
IMAGE_EXTENSIONS, dnd_has_extension, dnd_has_image, dnd_get_image, DownloadDialog)
|
||||
@ -94,13 +93,6 @@ def get_pixel_map():
|
||||
|
||||
def qimage_to_magick(img):
|
||||
ans = Image()
|
||||
if isosx:
|
||||
# For some reson, on OSX MagickConstituteImage fails, and I can't be
|
||||
# bothered figuring out why. Dumping to uncompressed PNG is reasonably
|
||||
# fast.
|
||||
raw = pixmap_to_data(img, 'PNG', quality=100)
|
||||
ans.load(raw)
|
||||
return ans
|
||||
fmt = get_pixel_map()
|
||||
if not img.hasAlphaChannel():
|
||||
if img.format() != img.Format_RGB32:
|
||||
@ -117,7 +109,7 @@ def qimage_to_magick(img):
|
||||
|
||||
def magick_to_qimage(img):
|
||||
fmt = get_pixel_map()
|
||||
# ImageMagick can output only output raw data in some formats that can be
|
||||
# ImageMagick can only output raw data in some formats that can be
|
||||
# read into QImage directly, if the QImage format is not one of those, use
|
||||
# PNG
|
||||
if fmt in {'RGBA', 'BGRA'}:
|
||||
|
@ -540,14 +540,14 @@ magick_Image_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
// Image.constitute {{{
|
||||
static PyObject *
|
||||
magick_Image_constitute(magick_Image *self, PyObject *args) {
|
||||
const char *map;
|
||||
Py_ssize_t width, height;
|
||||
PyObject *capsule;
|
||||
MagickBooleanType res;
|
||||
void *data;
|
||||
const char *map = NULL;
|
||||
unsigned int width = 0, height = 0;
|
||||
PyObject *capsule = NULL;
|
||||
MagickBooleanType res = MagickFalse;
|
||||
void *data = NULL;
|
||||
|
||||
NULL_CHECK(NULL)
|
||||
if (!PyArg_ParseTuple(args, "iisO", &width, &height, &map, &capsule)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "IIsO", &width, &height, &map, &capsule)) return NULL;
|
||||
|
||||
if (!PyCapsule_CheckExact(capsule)) {
|
||||
PyErr_SetString(PyExc_TypeError, "data is not a capsule object");
|
||||
@ -557,7 +557,7 @@ magick_Image_constitute(magick_Image *self, PyObject *args) {
|
||||
data = PyCapsule_GetPointer(capsule, PyCapsule_GetName(capsule));
|
||||
if (data == NULL) return NULL;
|
||||
|
||||
res = MagickConstituteImage(self->wand, width, height, map, CharPixel, data);
|
||||
res = MagickConstituteImage(self->wand, (size_t)width, (size_t)height, map, CharPixel, data);
|
||||
|
||||
if (!res)
|
||||
return magick_set_exception(self->wand);
|
||||
|
Loading…
x
Reference in New Issue
Block a user