Here an example program, which uses `copyMem` from a Pixie image to a NiGui canvas.
(Tested under Linux/Gtk) import std/math import pixie import NiGui const width = 500 const height = 500 app.init() var window = newWindow("Pixie+NiGui Example") window.width = width window.height = height var control1 = newControl() window.add(control1) control1.widthMode = WidthMode_Fill control1.heightMode = HeightMode_Fill var niGuiImage = nigui.newImage() niGuiImage.resize(width, height) control1.onDraw = proc (event: DrawEvent) = let canvas = event.control.canvas let image = newImage(width, height) let ctx = newContext(image) # Background image.fill(rgba(255, 255, 255, 255)) # Line ctx.strokeStyle = rgba(0, 0, 255, 255) ctx.lineWidth = 10 ctx.lineCap = RoundCap ctx.strokeSegment(segment(vec2(10, 10), vec2(width - 10, height - 10))) # Rect ctx.fillStyle = rgba(0, 255, 0, 255) ctx.translate(100, 200) ctx.rotate(45 * PI / 180) ctx.fillRect(rect(vec2(0, 0), vec2(100, 100))) ctx.strokeRect(rect(vec2(0, 0), vec2(100, 100))) # Text block: const text = "Text with Pixie" let font = readFont("/usr/share/fonts/noto/NotoSans-Regular.ttf") font.size = 40 font.paint.color = color(0, 0, 0) image.fillText(font.typeset(text), translate(vec2(200, 40))) # Draw Pixie image to drawing area var niGuiImageData = niGuiImage.beginPixelDataAccess() copyMem(niGuiImageData[0].addr, image.data[0].addr, width * height * 4) niGuiImage.endPixelDataAccess() event.control.canvas.drawImage(niGuiImage, 0, 0) # Text native block: const text = "Text with NiGui" canvas.fontSize = 40 * 1.1 canvas.textColor = nigui.rgb(0, 0, 0) canvas.drawText(text, 200, 90) window.show() app.run() Run