Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@hostilefork

Description

@hostilefork

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions