Type: Package
Title: Read and Write QOI Images
Date: 2024-04-17
Version: 0.1.0
Author: Johannes Friedrich [aut, trl, cre], Dominic Szablewski [cph] (C library 'qoi')
Maintainer: Johannes Friedrich <Johannes.Friedrich@posteo.de>
URL: https://github.com/JohannesFriedrich/qoi4R
BugReports: https://github.com/JohannesFriedrich/qoi4R/issues
Description: The new QOI file format offers a very simple but efficient image compression algorithm. This package provides an easy and simple way to read, write and display bitmap images stored in the QOI (Quite Ok Image) format. It can read and write both files and in-memory raw vectors.
License: MIT + file LICENSE
Encoding: UTF-8
NeedsCompilation: yes
RoxygenNote: 7.3.1
Depends: R (≥ 2.10)
LazyData: true
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
Packaged: 2024-04-17 17:25:47 UTC; johannes
Repository: CRAN
Date/Publication: 2024-04-17 17:40:12 UTC

RGBA values for the Rlogo (https://www.r-project.org/logo/)

Description

RGBA values for the Rlogo (https://www.r-project.org/logo/)

Format

[matrix] with 561 x 724 x 4 elements

Author(s)

Johannes Friedrich


Read an QOI image into a RGB(A) raster array

Description

Read an QOI image into a RGB(A) raster array

Usage

readQOI(qoi_image_path)

Arguments

qoi_image_path

character (required): Path to a stored qoi-image

Value

A matrix with integer (0-255) RGB(A) values with dimensions height x width x channels. Until now 3 (RGB) and 4 (RGBA) channels are integrated in the specification. If the decoding went wrong the returned value is NULL.

Author(s)

Johannes Friedrich

Examples

## (1) Read RGBA values from file
path <- system.file("extdata", "Rlogo.qoi", package="qoi")
rlogo_qoi <- readQOI(path)
dim(rlogo_qoi)

## (2) plot them
plot.new()

Write an QOI image from an RGB(A) raster array or matrix

Description

Write an QOI image from an RGB(A) raster array or matrix

Usage

writeQOI(image, target = raw())

Arguments

image

matrix (required): Image represented by a integer matrix or array with values in the range of 0 to 255.

target

character or connections or raw: Either name of the file to write, a binary connection or a raw vector (raw() - the default - is good enough) indicating that the output should be a raw vector.

Value

The result is either stored in a file (if target is a file name), in a raw vector (if target is a raw vector) or sent to a binary connection.

Author(s)

Johannes Friedrich

Examples

## (1) Write to raw() -> see bytes
bin <- writeQOI(Rlogo_RGBA)
rawToChar(head(bin)) ## qoif

## Not run: 
## (2) Write to a *.qoi file
writeQOI(Rlogo_RGBA, "Rlogo_RGBA.qoi")

## End(Not run)