Braille coder fix for DirectClass images
Samuel Thibault <[email protected]> Fri, 23 Oct 2009 16:02:58 +0200
| Newsgroups | gmane.comp.video.image-magick.devel |
|---|---|
| Message-ID | <[email protected]> |
--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello,
The braille coder wasn't handling the DirectClass image case, leading to
a crash, here is a patch to fix it.
Samuel
--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch
--- coders/braille.c.backup 2009-10-23 14:07:36.000000000 +0200
+++ coders/braille.c 2009-10-23 15:47:55.000000000 +0200
@@ -247,12 +247,15 @@
}
(void) SetImageType(image,BilevelType);
- polarity=(IndexPacket) (PixelIntensityToQuantum(&image->colormap[0]) >=
- (Quantum) (QuantumRange/2));
- if (image->colors == 2)
- polarity=(IndexPacket)
- (PixelIntensityToQuantum(&image->colormap[0]) >=
- PixelIntensityToQuantum(&image->colormap[1]));
+ if (image->storage_class == PseudoClass) {
+ polarity=(IndexPacket) (PixelIntensityToQuantum(&image->colormap[0]) >=
+ (Quantum) (QuantumRange/2));
+ if (image->colors == 2)
+ polarity=(IndexPacket)
+ (PixelIntensityToQuantum(&image->colormap[0]) >=
+ PixelIntensityToQuantum(&image->colormap[1]));
+ polarity = 0;
+ }
for (y=0; y < (long) image->rows; y+=cell_height)
{
if ((y+cell_height) > image->rows)
@@ -270,8 +273,12 @@
do
{
-#define do_cell(dx,dy,bit) \
- cell |= (indexes[x+dx+dy*image->columns]==polarity)<<bit;
+#define do_cell(dx,dy,bit) do { \
+ if (image->storage_class == PseudoClass) \
+ cell |= (indexes[x+dx+dy*image->columns] == polarity) << bit; \
+ else \
+ cell |= (p[x+dx+dy*image->columns].green == 0) << bit; \
+} while (0)
do_cell(0,0,0);
if (two_columns)
--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Magick-developers mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-developers
--7AUc2qLy4jB3hD7Z--