packages feed

JuicyPixels 3.1.3 → 3.1.3.1

raw patch · 4 files changed

+17/−9 lines, 4 files

Files

JuicyPixels.cabal view
@@ -1,5 +1,5 @@ Name:                JuicyPixels
-Version:             3.1.3
+Version:             3.1.3.1
 Synopsis:            Picture loading/serialization (in png, jpeg, bitmap, gif, tiff and radiance)
 Description:
     <<data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADABAMAAACg8nE0AAAAElBMVEUAAABJqDSTWEL/qyb///8AAABH/1GTAAAAAXRSTlMAQObYZgAAAN5JREFUeF7s1sEJgFAQxFBbsAV72v5bEVYWPwT/XDxmCsi7zvHXavYREBDI3XP2GgICqBBYuwIC+/rVayPUAyAg0HvIXBcQoDFDGnUBgWQQ2Bx3AYFaRoBpAQHWb3bt2ARgGAiCYFFuwf3X5HA/McgGJWI2FdykCv4aBYzmKwDwvl6NVmUAAK2vlwEALK7fo88GANB6HQsAAAAAAAAA7P94AQCzswEAAAAAAAAAAAAAAAAAAICzh4UAO4zWAYBfRutHA4Bn5C69JhowAMGoBaMWDG0wCkbBKBgFo2AUAACPmegUST/IJAAAAABJRU5ErkJggg==>>
@@ -26,7 +26,7 @@ Source-Repository this
     Type:      git
     Location:  git://github.com/Twinside/Juicy.Pixels.git
-    Tag:       v3.1.3
+    Tag:       v3.1.3.1
 
 Flag Mmap
     Description: Enable the file loading via mmap (memory map)
changelog view
@@ -1,6 +1,10 @@ -*-change-log-*-
 
-v3.1.3
+v3.1.3.1 January 2014
+ * Fixing color counting function in color quantisation.
+ * Adding missing documentation for foreign pointer import.
+
+v3.1.3 January 2014
  * Adding palette creation (color Quantization) by Jeffrey Rosenbluth.
  * Adding support for Gif writing
  * Adding support for Gif animation writing
src/Codec/Picture/ColorQuant.hs view
@@ -118,15 +118,14 @@       paletteList)
 
 isColorCountBelow :: Int -> Image PixelRGB8 -> (Set.Set PixelRGB8, Bool)
-isColorCountBelow maxColorCount img = go 0 0 Set.empty
+isColorCountBelow maxColorCount img = go 0 Set.empty
   where rawData = imageData img
         maxIndex = VS.length rawData
         
-        go !count !idx !allColors
-            | count > maxColorCount = (Set.empty, False)
+        go !idx !allColors
+            | Set.size allColors > maxColorCount = (Set.empty, False)
             | idx >= maxIndex - 2 = (allColors, True)
-            | otherwise = go (count + 1) (idx + 3)
-                        $ Set.insert px allColors
+            | otherwise = go (idx + 3) $ Set.insert px allColors
                 where px = unsafePixelAt rawData idx 
 
 vecToPalette :: Vector PixelRGB8 -> Palette
src/Codec/Picture/VectorByteConversion.hs view
@@ -23,9 +23,14 @@   where (ptr, offset, len) = unsafeToForeignPtr vec
         size = sizeOf (undefined :: a)
 
+-- | Import a image from an unsafe pointer
+-- The pointer must have a size of width * height * componentCount px
 imageFromUnsafePtr :: forall px
                     . (Pixel px, (PixelBaseComponent px) ~ Word8)
-                   => Int -> Int -> ForeignPtr Word8 -> Image px
+                   => Int -- ^ Width in pixels
+                   -> Int -- ^ Height in pixels
+                   -> ForeignPtr Word8 -- ^ Pointer to the raw data
+                   -> Image px
 imageFromUnsafePtr width height ptr =
     Image width height $ unsafeFromForeignPtr0 ptr size
       where compCount = componentCount (undefined :: px)