Format.hx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C)2005-2018 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. Upscale/downscale an image.
  57. Currently supported flag bits: 1 = bilinear filtering
  58. **/
  59. @:hlNative("fmt","img_scale")
  60. 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 ) {
  61. }
  62. /**
  63. Performs a cryptographic digest of some bytes.
  64. 0 = Md5 , 1 = Sha1 , 2 = Crc32, 3 = Adler32
  65. Set 256 flag to tell the src are String bytes.
  66. **/
  67. @:hlNative("fmt", "digest")
  68. public static function digest( out : hl.Bytes, src : hl.Bytes, srcLen : Int, algorithm : Int ) {
  69. }
  70. }
  71. #if !hl_disable_mikkt
  72. class Mikktspace {
  73. public var buffer : hl.BytesAccess<Single>;
  74. public var stride : Int;
  75. public var xPos : Int;
  76. public var normalPos : Int;
  77. public var uvPos : Int;
  78. public var tangents : hl.BytesAccess<Single>;
  79. public var tangentStride : Int;
  80. public var tangentPos : Int;
  81. public var indexes : hl.BytesAccess<Int>;
  82. public var indices : Int;
  83. public function new() {
  84. }
  85. public function compute( threshold = 180. ) {
  86. if( !_compute(this,threshold) ) throw "assert";
  87. }
  88. @:hlNative("fmt","compute_mikkt_tangents") static function _compute( m : Dynamic, threshold : Float ) : Bool {
  89. return false;
  90. }
  91. }
  92. #end