Images.html 5.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!DOCTYPE html> <HTML lang=en> <HEAD> <STYLE>
  2. body { background-color: #EEFFEE; font-size: 1.0rem; font-family: Arial; max-width: 60rem;
  3. color: #000000; margin: 0px;
  4. padding-left: 0px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px; }
  5. H1 { padding-left: 10px; padding-right: 0px; padding-top: 10px; padding-bottom: 10px; font-size: 1.4rem; }
  6. H2 { padding-left: 10px; padding-right: 0px; padding-top: 10px; padding-bottom: 0px; font-size: 1.2rem; }
  7. blockquote {
  8. tab-size: 3rem;
  9. color: #88FF88; background: #000000;
  10. font-size: 0.95rem; font-family: monospace;
  11. padding-left: 5px; padding-right: 5px;
  12. padding-top: 5px; padding-bottom: 5px;
  13. }
  14. P { padding-left: 20px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px; }
  15. IMG { padding-left: 0px; padding-right: 0px; padding-top: 2px; padding-bottom: 0px;
  16. max-width: 100%; }
  17. A { display: inline; border-radius: 4px;
  18. font-size: 1.0rem; font-family: Arial; color: #000044; text-decoration: none;
  19. padding-left: 4px; padding-right: 4px; padding-top: 4px; padding-bottom: 4px; }
  20. A:hover { color: #FFFF00; background: #000044; }
  21. A:active { color: #FFFFFF; background: #444444; }
  22. </STYLE> </HEAD> <BODY>
  23. <IMG SRC="Images/Title.png" ALT="Images/Title.png">
  24. <P>
  25. <A href="Manual.html">Back to main page</A>
  26. </P><P>
  27. </P><H1> Images</H1><P>All images are passed using reference counted handles so that they are automatically cleaned up when the last handle is freed.
  28. Only having one way to pass images hidden behind a referebce counted handle type removes the burden of remembering
  29. if you passed it as a value, reference, pointer, shared pointer or unique pointer.
  30. There's just one way to pass images, using the safe handles.
  31. By using global methods for all image operations, accidentally calling a method on a null objects
  32. can be caught safely instead of triggering undefined behaviour with random crashes.
  33. 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.
  34. </P><IMG SRC="Images/Border.png"><P>
  35. </P><H2> ImageU8</H2><P>The most basic image format used for 8-bit gray-scale images using 0 for black and 255 for white.
  36. Can be displayed by drawing it using draw_copy onto a color image for automatic conversion.
  37. </P><IMG SRC="Images/Border.png"><P>
  38. </P><H2> ImageU16</H2><P>If 8-bit precision is not enough but you still want the determinism of using integers, there's also a 16-bit monochrome image.
  39. 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).
  40. </P><IMG SRC="Images/Border.png"><P>
  41. </P><H2> ImageF32</H2><P>32-bit floating-point images offer more flexibility for advanced image filtering, but does not have the same determinism as integer formats.
  42. Avoid exact equality comparisons using floating-point numbers, because it's always an approximation and the rounding method may differ between CPU models.
  43. </P><IMG SRC="Images/Border.png"><P>
  44. </P><H2> ImageRgbaU8</H2><P>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.
  45. </P><IMG SRC="Images/Border.png"><P>
  46. </P><H2> Aligned images</H2><P>Then there's the aligned image types AlignedImageU8, AlignedImageU16, AlignedImageF32 and AlignedImageRgbaU8.
  47. Aligned images are created from the constructors by default because new images are always aligned for SIMD vectorization.
  48. Aligned integer images (AlignedImageU8, AlignedImageU16 and AlignedImageRgbaU8) use DSR_DEFAULT_ALIGNMENT to be compatible with the largest supported SIMD vector capable of processing all element types, called the X vector (F32xX, I32xX, U32xX, U16xX, U8xX).
  49. Aligned float images (AlignedImageF32) use DSR_FLOAT_ALIGNMENT to be compatible with the largest supported floating-point SIMD vector, called the F vector (F32xF).
  50. The F vector size is as least as large as the X vector size, so floating-point images aligned for the F vector are also aligned for the X vectors.
  51. Non-aligned images are created as sub-images pointing to existing pixel buffers without cloning.
  52. </P><IMG SRC="Images/Border.png"><P>
  53. </P><H2> Ordered images</H2><P>The ordered image type OrderedImageRgbaU8 is aligned just like AlignedImageU8 but also ensures that
  54. the pack order is RGBA on every platform, which makes it easy to manuipulate using pointers.
  55. AlignedImageRgbaU8 can however be dynamically set to different internal pack orders using the
  56. constructor image_create_RgbaU8_native, which is used by the window's canvas.
  57. </P><IMG SRC="Images/Border.png"><P>
  58. </P><H2> Loading images</H2><P>image_load_RgbaU8 can be used to load an RGBA image from a file.
  59. If you only need one channel, then use image_get_red on the result to extract the first channel from a gray-scale image.
  60. </P><IMG SRC="Images/Border.png"><P>
  61. </P><H2> Saving images</H2><P>image_save can be used to save an RGBA image to a file.
  62. </P><IMG SRC="Images/Border.png"><P>
  63. </P>
  64. </BODY> </HTML>