changeset 1343:edb0b650fc5f

add: allow adding single images to image array
author sam <sam@basx.dev>
date Mon, 26 Aug 2024 19:39:12 +0700
parents 34ae5835bfa8
children 18eff4d97ab0
files semicongine/image.nim
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/image.nim	Mon Aug 26 18:51:25 2024 +0700
+++ b/semicongine/image.nim	Mon Aug 26 19:39:12 2024 +0700
@@ -105,6 +105,15 @@
     loadImageData[T](loadResource_intern(path, package = package).readAll())
   result = Image[T](width: width, height: height, data: data)
 
+proc addImage*[T: PixelType](imageArray: var ImageArray[T], image: sink Image[T]) =
+  assert image.width == imageArray.width,
+    "Image needs to have same dimension as ImageArray to be added"
+  assert image.height == imageArray.height,
+    "Image needs to have same dimension as ImageArray to be added"
+
+  inc image.nLayers
+  imageArray.data.add image.data
+
 proc loadImageArray*[T: PixelType](
     paths: openArray[string], package = DEFAULT_PACKAGE
 ): ImageArray[T] =