Skip to content

Instantly share code, notes, and snippets.

@folkertdev
Created December 30, 2019 19:00
Show Gist options
  • Save folkertdev/24c0508348646677c00a572d97002f00 to your computer and use it in GitHub Desktop.
Save folkertdev/24c0508348646677c00a572d97002f00 to your computer and use it in GitHub Desktop.
bug in elm-image
module Issue4 exposing (suite)
import Bytes exposing (Bytes)
import Bytes.Encode as Encode
import Expect
import Image
import Test exposing (test)
suite =
case Image.decode spriteBytes of
Just image1 ->
let
image2 =
image1
|> Image.toArray
|> Image.fromArray 10
in
test "fromArray << toArray is equivalent to identity" <|
\_ ->
let
n =
10
a =
Image.toList image1
|> List.take n
b =
Image.toList image2
|> List.take n
in
a
|> Expect.equal b
Nothing ->
Debug.todo "invalid image"
spriteBytes : Bytes
spriteBytes =
spriteByteValues
|> List.map Encode.unsignedInt8
|> Encode.sequence
|> Encode.encode
spriteByteValues : List Int
spriteByteValues =
[ 0x89
, 0x50
, 0x4E
, 0x47
, 0x0D
, 0x0A
, 0x1A
, 0x0A
, 0x00
, 0x00
, 0x00
, 0x0D
, 0x49
, 0x48
, 0x44
, 0x52
, 0x00
, 0x00
, 0x00
, 0x0A
, 0x00
, 0x00
, 0x00
, 0x0A
, 0x08
, 0x03
, 0x00
, 0x00
, 0x00
, 0xBA
, 0xEC
, 0x3F
, 0x8F
, 0x00
, 0x00
, 0x00
, 0x01
, 0x73
, 0x52
, 0x47
, 0x42
, 0x00
, 0xAE
, 0xCE
, 0x1C
, 0xE9
, 0x00
, 0x00
, 0x00
, 0x60
, 0x50
, 0x4C
, 0x54
, 0x45
, 0x00
, 0x00
, 0x00
, 0x22
, 0x20
, 0x34
, 0x45
, 0x28
, 0x3C
, 0x66
, 0x39
, 0x31
, 0x8F
, 0x56
, 0x3B
, 0xDF
, 0x71
, 0x26
, 0xD9
, 0xA0
, 0x66
, 0xEE
, 0xC3
, 0x9A
, 0xFB
, 0xF2
, 0x36
, 0x99
, 0xE5
, 0x50
, 0x6A
, 0xBE
, 0x30
, 0x37
, 0x94
,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0xBD
, 0x43
, 0x60
, 0x00
, 0x00
, 0x00
, 0x00
, 0x49
, 0x45
, 0x4E
, 0x44
, 0xAE
, 0x42
, 0x60
, 0x82
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment