Image convert example
Example to read one image in and write another out. You need to provide image_input.tga as an input image and place it in current working directory.
Compilation
Easiest way to get this example running is to go to examples directory in package root, and run:
$ ./build.sh image_convert
build.sh script compiles Ano script to C, copies source files in place and pops up instructions what to do next. Follow them. Check also examples/README for more info.
Preview
; ------------------------------------------------------------------------------
; image_convert.ano
;
; To compile:
;
; $ ./build/ano ./examples/image_convert/image_convert.ano > \
; engine/dsl_ano.h
; ------------------------------------------------------------------------------
;
; @ANO_SCRIPT_NAME image_convert
; @ANO_SCRIPT_VERSION 0.0.1
; @ANO_SCRIPT_DESCRIPTION Simple image format converter
;
; @ANO_FLAGS_USE_PROTOS [ ]
; @ANO_FLAGS_VAR_NAME_SUBS [ ]
; @ANO_FLAGS_VAR_WARN_UNUSED [ ]
;
; Copyright © 2016-2026, Jani Salonen <salojan@goto10.co>
; All rights reserved.
;
; Example to read one image in and write another out. You need to provide
; image_input.tga as an input image.
;
define img_in ("image_input.tga")
define img_out ("image_input.rgb")
main [exit: 0] {
; Read TGA image in and write it out using RGB format.
;
image_read (img_in)
cmp rc (% 0)
jne "do_convert"
print "Failed to read input image. Abort.\n"
exit
do_convert:
mov input_image (rc)
dump input_image
image_write_rgb (img_out, input_image)
cmp rc (0)
je "convert_ok"
print "Failed to write to output image. Abort.\n"
exit
convert_ok:
print "Image is converted succesfully.\n"
}
; ------------------------------------------------------------------------------ ; image_convert.w2c ; ; To compile: ; ; $ ./build/widget ./examples/image_convert/image_convert.w2c > \ ; engine/widget_defs.h ; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------ ; image_convert.m2c ; ; To compile: ; ; $ ./build/menu ./examples/image_convert/image_convert.m2c > \ ; engine/menu_defs.h ; ------------------------------------------------------------------------------
Copyright © 2026, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.