PIKApp/plug-ins/script-fu/test/tests/PDB/image/image-indexed.scm

129 lines
3.5 KiB
Scheme
Raw Normal View History

2023-09-26 00:35:21 +02:00
; test Image of mode indexed methods of PDB
; Now independent of image ID
; Basic indexed tests
; an empty image for testing
(define newTestImage (car (pika-image-new 21 22 RGB)))
; Load test image that already has drawable
(define testImage (testing:load-test-image "wilber.png"))
; testImage is mode RGB
(assert `(=
(car (pika-image-get-base-type ,testImage))
RGB))
; method pika-image-convert-indexed yields truthy (now yields (#t) )
(assert `(pika-image-convert-indexed
,testImage
CONVERT-DITHER-NONE
CONVERT-PALETTE-GENERATE
2 ; color count
1 ; alpha-dither. FUTURE: #t
1 ; remove-unused. FUTURE: #t
"myPalette" ; ignored
))
; method pika-image-convert-indexed works even on empty image
(assert `(pika-image-convert-indexed
,newTestImage
CONVERT-DITHER-NONE
CONVERT-PALETTE-GENERATE
25 ; color count
1 ; alpha-dither. FUTURE: #t
1 ; remove-unused. FUTURE: #t
"myPalette" ; ignored
))
; conversion was effective:
; basetype of indexed image is INDEXED
(assert `(=
(car (pika-image-get-base-type ,testImage))
INDEXED))
; conversion was effective:
; basetype of indexed image is INDEXED
(assert `(=
(car (pika-image-get-base-type ,newTestImage))
INDEXED))
; testImage has a layer named same as file "wilber.png"
; TODO Why does "Background" work but app shows "wilber.png"
; drawable of indexed image is also indexed
(assert `(= (car (pika-drawable-is-indexed
; unwrap the drawable ID
(car (pika-image-get-layer-by-name ,testImage "Background"))))
1)) ; FUTURE #t
; colormaps of indexed images
; conversion was effective:
; indexed image has-a colormap
; colormap is-a vector of length zero, when image has no drawable.
; get-colormap returns (#( <bytes of color>))
; FIXME doc says num-bytes is returned, obsolete since GBytes
(assert `(=
(vector-length
(car (pika-image-get-colormap ,newTestImage)))
0))
; colormap is-a vector of length 3*<color count given during conversion>,
; when image has a drawable.
; 3*2=6
; FIXME doc says num-bytes is returned, obsolete since GBytes
(assert `(=
(vector-length
(car (pika-image-get-colormap ,testImage)))
(* 3 2)))
; set-colormap succeeds
; This tests marshalling of GBytes to PDB
(assert `(pika-image-set-colormap ,testImage #(1 1 1 9 9 9)))
; TODO set-colormap effective
; colormap vector is same as given
(assert `(equal?
(car (pika-image-get-colormap ,testImage))
#(1 1 1 9 9 9)))
; precision of indexed images
; indexed images have precision PRECISION-U8-NON-LINEAR
; FIXME annotation of PDB procedure says PIKA_PRECISION_U8
(assert `(=
(car (pika-image-get-precision ,testImage))
PRECISION-U8-NON-LINEAR ))
; !!! This depends on ID 4 for image
; convert precision of indexed images yields error
(assert-error `(car (pika-image-convert-precision
,newTestImage
PRECISION-DOUBLE-GAMMA))
"Procedure execution of pika-image-convert-precision failed on invalid input arguments: ")
; "Image '[Untitled]' (4) must not be of type 'indexed'"