Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure Out What To Do With IMAGE! Codec Tests #1152

Open
hostilefork opened this issue Jul 27, 2023 · 0 comments
Open

Figure Out What To Do With IMAGE! Codec Tests #1152

hostilefork opened this issue Jul 27, 2023 · 0 comments

Comments

@hostilefork
Copy link
Member

Ren-C's goal is to ponder and distill out the "timeless" elements of the language. The IMAGE! datatype was in the way of this, as it was very undercooked (the concept of treating a 2D matrix as a 1D series was never really hammered out).

The C code for doing image encoding and decoding was nothing special, and would be of little use in a web browser where the code is optimized and already available. So PNG, GIF, BMP, JPEG extensions were archived.

In some far future time maybe the code will be relevant. For now, it is not. These tests need to find a place in the archives:

Decoding

(image? decode 'bmp read %../fixtures/rebol-logo.bmp)
(image? decode 'gif read %../fixtures/rebol-logo.gif)
(image? decode 'jpeg read %../fixtures/rebol-logo.jpg)
(image? decode 'png read %../fixtures/rebol-logo.png)

; The results of decoding lossless encodings should be identical.
(
    bmp-img: decode 'bmp read %../fixtures/rebol-logo.bmp
    gif-img: decode 'gif read %../fixtures/rebol-logo.gif
    png-img: decode 'png read %../fixtures/rebol-logo.png
    did all [
        bmp-img == gif-img
        bmp-img == png-img
    ]
)

; Because there is more metadata in a PNG file than just the encoding, and
; compression choices may be different, you won't necessarily get the same
; bytes out when you re-encode a PNG.  It should be deterministic, though.
(
    png-img: decode 'png read %../fixtures/rebol-logo.png
    bmp-img: decode 'bmp read %../fixtures/rebol-logo.bmp

    png-bytes-png: encode 'png png-img
    png-bytes-bmp: encode 'png bmp-img

    did all [
        png-bytes-png = png-bytes-bmp
        (decode 'png png-bytes-png) = (decode 'png png-bytes-bmp)
    ]
)

Encoding

(out: encode 'bmp decode 'bmp src: read %../fixtures/rebol-logo.bmp out == src)
hostilefork added a commit that referenced this issue Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant