images.loader.gdiplus: both BGRA and BGRX formats are supported
parent
00c051cc8a
commit
8cd471eda6
|
@ -0,0 +1,9 @@
|
||||||
|
USING: images images.loader.gdiplus.private tools.test ;
|
||||||
|
IN: images.loader.gdiplus.tests
|
||||||
|
|
||||||
|
{ } [
|
||||||
|
BGRA check-pixel-format
|
||||||
|
BGRX check-pixel-format
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ RGB check-pixel-format ] [ unsupported-pixel-format? ] must-fail-with
|
|
@ -59,15 +59,14 @@ os windows? [
|
||||||
ubyte-components >>component-type
|
ubyte-components >>component-type
|
||||||
f >>upside-down? ;
|
f >>upside-down? ;
|
||||||
|
|
||||||
! Only one pixel format supported, but I can't find images in the
|
! Loaded images usually have the format BGRA, text rendered BGRX.
|
||||||
! wild, loaded using gdi+, in which the format is different.
|
|
||||||
ERROR: unsupported-pixel-format component-order ;
|
ERROR: unsupported-pixel-format component-order ;
|
||||||
|
|
||||||
: check-pixel-format ( image -- )
|
: check-pixel-format ( component-order -- )
|
||||||
component-order>> dup BGRA = [ drop ] [ unsupported-pixel-format ] if ;
|
dup { BGRX BGRA } member? [ drop ] [ unsupported-pixel-format ] if ;
|
||||||
|
|
||||||
: image>gdi+-bitmap ( image -- bitmap )
|
: image>gdi+-bitmap ( image -- bitmap )
|
||||||
dup check-pixel-format
|
dup component-order>> check-pixel-format
|
||||||
[ dim>> first2 ] [ rowstride PixelFormat32bppARGB ] [ bitmap>> ] tri
|
[ dim>> first2 ] [ rowstride PixelFormat32bppARGB ] [ bitmap>> ] tri
|
||||||
{ void* } [
|
{ void* } [
|
||||||
GdipCreateBitmapFromScan0 check-gdi+-status
|
GdipCreateBitmapFromScan0 check-gdi+-status
|
||||||
|
|
Loading…
Reference in New Issue