From 9d424cb1c8f3f90520ea87aff3d225f7ed6dbc70 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 15 Nov 2010 16:47:55 -0800 Subject: [PATCH] Fixed floating point exception in PixelArray() --- src/PixelArray.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/PixelArray.cc b/src/PixelArray.cc index fb83eef..528ac98 100644 --- a/src/PixelArray.cc +++ b/src/PixelArray.cc @@ -103,9 +103,16 @@ PixelArray::PixelArray(Canvas *canvas, int sx, int sy, int width, int height): // undo premultiplication dst[bx + 3] = a; - dst[bx + 0] = r * 255 / a; - dst[bx + 1] = g * 255 / a; - dst[bx + 2] = b * 255 / a; + // TODO: abstract + if (a) { + dst[bx + 0] = r * 255 / a; + dst[bx + 1] = g * 255 / a; + dst[bx + 2] = b * 255 / a; + } else { + dst[bx + 0] = r; + dst[bx + 1] = g; + dst[bx + 2] = b; + } } dst += dstStride; }