Format.hx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package hl;
  23. enum abstract PixelFormat(Int) {
  24. var RGB = 0;
  25. var BGR = 1;
  26. var RGBX = 2;
  27. var BGRX = 3;
  28. var XBGR = 4;
  29. var XRGB = 5;
  30. var GRAY = 6;
  31. var RGBA = 7;
  32. var BGRA = 8;
  33. var ABGR = 9;
  34. var ARGB = 10;
  35. var CMYK = 11;
  36. }
  37. /**
  38. These are the bindings for the HL `fmt.hdll` library, which contains various low level formats handling.
  39. **/
  40. class Format {
  41. /**
  42. Decode JPG data into the target buffer.
  43. **/
  44. @:hlNative("fmt","jpg_decode")
  45. public static function decodeJPG( src : hl.Bytes, srcLen : Int, dst : hl.Bytes, width : Int, height : Int, stride : Int, format : PixelFormat, flags : Int ) : Bool {
  46. return false;
  47. }
  48. /**
  49. Decode PNG data into the target buffer.
  50. **/
  51. @:hlNative("fmt","png_decode")
  52. public static function decodePNG( src : hl.Bytes, srcLen : Int, dst : hl.Bytes, width : Int, height : Int, stride : Int, format : PixelFormat, flags : Int ) : Bool {
  53. return false;
  54. }
  55. /**
  56. Decode any image data into ARGB pixels
  57. **/
  58. #if (hl_ver >= version("1.10.0"))
  59. @:hlNative("fmt","dxt_decode")
  60. public static function decodeDXT( src : hl.Bytes, dst : hl.Bytes, width : Int, height : Int, dxtFormat : Int ) : Bool {
  61. return false;
  62. }
  63. #end
  64. /**
  65. Upscale/downscale an image.
  66. Currently supported flag bits: 1 = bilinear filtering
  67. **/
  68. @:hlNative("fmt","img_scale")
  69. public static function scaleImage( out : hl.Bytes, outPos : Int, outStride : Int, outWidth : Int, outHeight : Int, _in : hl.Bytes, inPos : Int, inStride : Int, inWidth : Int, inHeight : Int, flags : Int ) {
  70. }
  71. /**
  72. Performs a cryptographic digest of some bytes.
  73. 0 = Md5 , 1 = Sha1 , 2 = Crc32, 3 = Adler32
  74. Set 256 flag to tell the src are String bytes.
  75. **/
  76. @:hlNative("fmt", "digest")
  77. public static function digest( out : hl.Bytes, src : hl.Bytes, srcLen : Int, algorithm : Int ) {
  78. }
  79. }
  80. class Mikktspace {
  81. public var buffer : hl.BytesAccess<Single>;
  82. public var stride : Int;
  83. public var xPos : Int;
  84. public var normalPos : Int;
  85. public var uvPos : Int;
  86. public var tangents : hl.BytesAccess<Single>;
  87. public var tangentStride : Int;
  88. public var tangentPos : Int;
  89. public var indexes : hl.BytesAccess<Int>;
  90. public var indices : Int;
  91. public function new() {
  92. }
  93. public function compute( threshold = 180. ) {
  94. if( !_compute(this,threshold) ) throw "assert";
  95. }
  96. @:hlNative("fmt","compute_mikkt_tangents") static function _compute( m : Dynamic, threshold : Float ) : Bool {
  97. return false;
  98. }
  99. }