From 72b343ce03c39b765926de373eee0aee12dbf9b6 Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Mon, 9 Feb 2009 21:15:57 -0600 Subject: [PATCH] fix images tests --- extra/images/bitmap/bitmap-tests.factor | 13 +++++-------- extra/images/bitmap/bitmap.factor | 11 ++++++++--- extra/images/tiff/tiff-tests.factor | 5 ++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/extra/images/bitmap/bitmap-tests.factor b/extra/images/bitmap/bitmap-tests.factor index 6865bfee3c..a2b3188749 100644 --- a/extra/images/bitmap/bitmap-tests.factor +++ b/extra/images/bitmap/bitmap-tests.factor @@ -2,23 +2,20 @@ USING: images.bitmap images.viewer io.encodings.binary io.files io.files.unique kernel tools.test ; IN: images.bitmap.tests -: test-bitmap32-alpha ( -- path ) - "resource:extra/images/bitmap/test-images/32alpha.bmp" ; - : test-bitmap24 ( -- path ) - "resource:extra/images/bitmap/test-images/thiswayup24.bmp" ; + "resource:extra/images/test-images/thiswayup24.bmp" ; : test-bitmap16 ( -- path ) - "resource:extra/images/bitmap/test-images/rgb16bit.bmp" ; + "resource:extra/images/test-images/rgb16bit.bmp" ; : test-bitmap8 ( -- path ) - "resource:extra/images/bitmap/test-images/rgb8bit.bmp" ; + "resource:extra/images/test-images/rgb8bit.bmp" ; : test-bitmap4 ( -- path ) - "resource:extra/images/bitmap/test-images/rgb4bit.bmp" ; + "resource:extra/images/test-images/rgb4bit.bmp" ; : test-bitmap1 ( -- path ) - "resource:extra/images/bitmap/test-images/1bit.bmp" ; + "resource:extra/images/test-images/1bit.bmp" ; [ t ] [ diff --git a/extra/images/bitmap/bitmap.factor b/extra/images/bitmap/bitmap.factor index 220cdc153f..eb31dcd385 100755 --- a/extra/images/bitmap/bitmap.factor +++ b/extra/images/bitmap/bitmap.factor @@ -97,7 +97,7 @@ M: bitmap-magic summary dup rgb-quads-length read >>rgb-quads dup color-index-length read >>color-index ; -: load-bitmap ( path -- bitmap ) +: load-bitmap-data ( path -- bitmap ) binary [ bitmap new parse-file-header parse-bitmap-header parse-bitmap @@ -106,14 +106,19 @@ M: bitmap-magic summary : alpha-channel-zero? ( bitmap -- ? ) buffer>> 4 <sliced-groups> 3 <column> [ 0 = ] all? ; +: process-bitmap-data ( bitmap -- bitmap ) + dup raw-bitmap>buffer >>buffer + dup alpha-channel-zero? >>alpha-channel-zero? ; + +: load-bitmap ( path -- bitmap ) + load-bitmap-data process-bitmap-data ; + : bitmap>image ( bitmap -- bitmap-image ) { [ width>> ] [ height>> ] [ bit-count>> ] [ buffer>> ] } cleave bitmap-image new-image ; M: bitmap-image load-image* ( path bitmap -- bitmap-image ) drop load-bitmap - dup raw-bitmap>buffer >>buffer - dup alpha-channel-zero? >>alpha-channel-zero? bitmap>image ; : write2 ( n -- ) 2 >le write ; diff --git a/extra/images/tiff/tiff-tests.factor b/extra/images/tiff/tiff-tests.factor index dcc4b05eab..9905e7ad79 100755 --- a/extra/images/tiff/tiff-tests.factor +++ b/extra/images/tiff/tiff-tests.factor @@ -4,8 +4,7 @@ USING: tools.test images.tiff ; IN: images.tiff.tests : tiff-test-path ( -- path ) - "resource:extra/images/tiff/rgb.tiff" ; + "resource:extra/images/test-images/rgb.tiff" ; : tiff-test-path2 ( -- path ) - "resource:extra/images/tiff/octagon.tiff" ; - + "resource:extra/images/test-images/octagon.tiff" ;