using Images, TestImages, Compose, Color
import Compose.compose
function compose(img::Image, c::Context)
width, height = size(img)
surface = Cairo.CairoARGBSurface(zeros(Uint32, height, width))
draw(PNG(surface), c)
overlay = reinterpret(BGRA{FixedPointNumbers.Ufixed8}, surface.data)
outimg = similar(img)
for i=1:width, j=1:height
alpha = overlay[i,j].alpha
overlay_pixel = convert(eltype(img), overlay[i,j])
beta = one(alpha) - alpha
outimg[i,j] = beta*img[i,j] + alpha*overlay_pixel
end
outimg
endtestimg = testimage("lighthouse")
width,height = size(testimg)
c = compose(context(), line([(1,1), (width,height)]))
c = compose(c, line([(width,1), (width/2,height/2)]))
c = compose(c, stroke(color("yellow")))
c = compose(context(units=UnitBox(0, 0, width, height)), c)
compose(testimg, c)