Open ramiromagno opened 2 years ago
Nevermind, I realised just now that image_data()
gives exactly what I wanted.
I am getting Professor Frink upside down and a small white rectangle...
# Load image using `{magick}`
img <- image_read("https://jeroen.github.io/images/frink.png")
data <- image_data(img)
img_width <- dim(data)[2]
img_height <- dim(data)[3]
gl_tex_image_2d(GL$TEXTURE_2D, 0L, GL$RGBA, img_width, img_height, 0L, GL$RGBA, GL$UNSIGNED_BYTE, data)
gl_generate_mipmap(GL$TEXTURE_2D)
Hi Jeroen,
I would like to use
{magick}
to conveniently import images into R and pass the image data into a function at C level. Is this possible?My use case is passing image data into the OpenGL function, and perhaps also access its metadata (such as number of channels, depth, dimensions)?
glTexImage2D(..., data)
to load a texture into the GPU, where data is the address of the image data. So, is there a safe way of getting the address of a 'magick-image'Dankje!