Extra "ports" of juce-based plugins using the distrho build system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.7KB

  1. --- Image.
  2. -- Images can be loaded from a file, or created as temporary graphics targets.
  3. --
  4. -- Is a pointer to a [JUCE Image](http://www.juce.com/api/classImage.html),
  5. -- and wraps some [JUCE ImageFileFormat](http://www.juce.com/api/classImageFileFormat.html)
  6. -- functionality.
  7. -- @classmod juce.Image
  8. ffi.cdef [[
  9. pImage Image_new();
  10. pImage Image_new2(int pixelFormat, int imageWidth, int imageHeight, bool clearImage);
  11. void Image_delete(pImage i);
  12. bool Image_isValid(pImage i);
  13. pImage ImageFileFormat_loadFrom2(const char *filename);
  14. ]]
  15. local Image = setmetatable ({}, {
  16. --- Load an image from a file.
  17. -- The path can be absolute or relative to the protoplug directory.
  18. -- To check if the file was loaded successfully, use @{isValid}.
  19. -- @param filename
  20. -- @within Constructors
  21. -- @constructor
  22. -- @function Image
  23. --- Create a temporary in-memory image.
  24. -- @tparam juce.Image.PixelFormat pixelFormat
  25. -- @param imageWidth
  26. -- @param imageHeight
  27. -- @tparam boolean clearImage fill the image with black
  28. -- @within Constructors
  29. -- @constructor
  30. -- @function Image
  31. __call = function(self, ...)
  32. if select("#", ...)==4 then
  33. return ffi.gc(
  34. protolib.Image_new2(...),
  35. protolib.Image_delete
  36. )
  37. else
  38. return ffi.gc(
  39. protolib.ImageFileFormat_loadFrom2(...),
  40. protolib.Image_delete
  41. )
  42. end
  43. end;
  44. })
  45. local Image_mt = {
  46. -- methods
  47. __index = {
  48. --- Check Image validity.
  49. -- @treturn boolean whether the image is valid and can be used.
  50. -- @function isValid
  51. isValid = function (self)
  52. return protolib.Image_isValid(self)
  53. end;
  54. }
  55. }
  56. ffi.metatype("pImage", Image_mt);
  57. --- Pixel formats.
  58. -- @table juce.Image.PixelFormat
  59. Image.PixelFormat = {
  60. UnknownFormat = 0; -- 0
  61. RGB = 1; -- 1
  62. ARGB = 2; -- 2
  63. SingleChannel = 3 -- 3
  64. }
  65. return Image