Images.txt 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <- Manual.html | Back to main page
  2. Title: Images
  3. All images are passed using reference counted handles so that they are automatically cleaned up when the last handle is freed.
  4. Only having one way to pass images hidden behind a referebce counted handle type removes the burden of remembering
  5. if you passed it as a value, reference, pointer, shared pointer or unique pointer.
  6. There's just one way to pass images, using the safe handles.
  7. By using global methods for all image operations, accidentally calling a method on a null objects
  8. can be caught safely instead of triggering undefined behaviour with random crashes.
  9. Always passing by reference for convenience however costs a little bit more to allocate, so don't create and destroy sub-images all the time.
  10. ---
  11. Title2: ImageU8
  12. The most basic image format used for 8-bit gray-scale images using 0 for black and 255 for white.
  13. Can be displayed by drawing it using draw_copy onto a color image for automatic conversion.
  14. ---
  15. Title2: ImageU16
  16. If 8-bit precision is not enough but you still want the determinism of using integers, there's also a 16-bit monochrome image.
  17. Just like 8-bit images, the visible range is 0 to 255 when converting automatically, but the 16-bit image has a higher range up to 65535 (2¹⁶ - 1).
  18. ---
  19. Title2: ImageF32
  20. 32-bit floating-point images offer more flexibility for advanced image filtering, but does not have the same determinism as integer formats.
  21. Avoid exact equality comparisons using floating-point numbers, because it's always an approximation and the rounding method may differ between CPU models.
  22. ---
  23. Title2: ImageRgbaU8
  24. A 32-bit color image format using 4 channels with 8 bits in each. The alpha channel can be used to represent opacity or any other information needed.
  25. ---
  26. Title2: Aligned images
  27. Then there's the aligned image types AlignedImageU8, AlignedImageU16, AlignedImageF32 and AlignedImageRgbaU8.
  28. Aligned images are created from the constructors by default because new images are always aligned for 128-bit SIMD vectorization.
  29. Non-aligned images are created as sub-images pointing to existing pixel buffers without cloning.
  30. ---
  31. Title2: Ordered images
  32. The ordered image type OrderedImageRgbaU8 is aligned just like AlignedImageU8 but also ensures that
  33. the pack order is RGBA on every platform, which makes it easy to manuipulate using pointers.
  34. AlignedImageRgbaU8 can however be dynamically set to different internal pack orders using the
  35. constructor image_create_RgbaU8_native, which is used by the window's canvas.
  36. ---
  37. Title2: Loading images
  38. image_load_RgbaU8 can be used to load an RGBA image from a file.
  39. If you only need one channel, then use image_get_red on the result to extract the first channel from a gray-scale image.
  40. ---
  41. Title2: Saving images
  42. image_save can be used to save an RGBA image to a file.
  43. ---