This repository has been archived by the owner on Feb 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Image Viewing
Sdanisch edited this page Aug 17, 2014
·
5 revisions
With GLPLot you can view basically every OpenGL texture. As GLTextures are not only used for images, but for all kinds of purposes, this is pretty helpful. You can create a texture from a matrix, or from a path pointing to an image. Most image formats are supported, thanks to the awesome package Images.jl. By now, you have some extended functionality available, like applying filter kernels and stretching the values to a certain range.
examples/image.jl:
using GLPlot, GLAbstraction
window = createdisplay()
# Using ImmutableArrays for colors (Vec4 --> Vector4{Float32):
a = Texture(Vec4[Vec4(i/512,j/512,0,1)for i=1:512, j=1:512])
# Without ImmutableArrays, the color dimension is not known and you need to supply it
b = Texture(Float32[(i*j)/512^2 for i=1:512, j=1:512], 1)
c = Texture("examples/mypicture.png")
# default usage will just bring the texture on your screen with zooming and panning enabled:
glplot(b)
# these are the keyword arguments:
# ; camera = OrthographicCamera(window.inputs), normrange=Vec2(0,1), kernel=1f0, filternorm=1f0)
# The kernel should be a Matrix{Float32} or Matrix{Vec1}.
# Matrix{Vec2/3/4} is currently not supported, but quite easy to implement
# normrange normalizes the values from normrange[1] to normrange[2] to 0->1
renderloop(window)