I am trying to import a gif and turn it into a grob to use it with the function annotation_custom in a ggplot, so far I imported it and have been able to turn it into an image.
So far this is what I have:
library(caTools)
require(ggplot2)
require(grid)
require(gridExtra)
y <- read.gif("http://blog.helpingadvisors.com/wp-content/uploads/2011/01/basketballcourt.gif")
and I get a list, so far I have been able to plot it:
image(y$image, col=y$col, main=y$comment, asp=1)
But I have tried to transform it to a grob:
a <- rasterGrob(image(y$image, col=y$col, main=y$comment, asp=1))
or try
raster(image(y$image, col=y$col, main=y$comment, asp=1))
and then save it as a grob, but since image returns class NULL it does not work.
I've also tried to use the matrix from y, but it gets really strange colours:
plot(raster(y$image))
and I really need the original colours