Пример #1
0
        public static byte[] Load(string fileName, out int x, out int y, out Components comp, Components desiredChannels = 0)
        {
            int nx;
            int ny;
            int ncomp;

            byte *data;

            fixed(byte *ptr = Encoding.UTF8.GetBytes(fileName + '\0'))
            {
                data = NativeStbImage.stbi_load(ptr, &nx, &ny, &ncomp, (int)desiredChannels);
            }

            x    = nx;
            y    = ny;
            comp = (Components)ncomp;

            byte[] res = new byte[x * y * (int)comp];

            fixed(byte *resPtr = res)
            {
                Buffer.MemoryCopy(data, resPtr, res.Length, res.Length);
            }

            NativeStbImage.stbi_image_free(data);

            return(res);
        }
Пример #2
0
        public static bool Is16Bit(string fileName)
        {
            bool res;

            fixed(byte *ptr = Encoding.UTF8.GetBytes(fileName + '\0'))
            {
                res = NativeStbImage.stbi_is_16_bit(ptr) == 1;
            }

            return(res);
        }
Пример #3
0
        public static bool Info(string fileName, out int x, out int y, out Components comp)
        {
            int nx;
            int ny;
            int ncomp;

            bool res;

            fixed(byte *ptr = Encoding.UTF8.GetBytes(fileName + '\0'))
            {
                res = NativeStbImage.stbi_info(ptr, &nx, &ny, &ncomp) == 1;
            }

            x    = nx;
            y    = ny;
            comp = (Components)ncomp;

            return(res);
        }
Пример #4
0
 public static void HdrToLdrGamma(float gamma)
 {
     NativeStbImage.stbi_hdr_to_ldr_gamma(gamma);
 }
Пример #5
0
 public static void SetFlipVerticallyOnLoad(bool shouldFlip)
 {
     NativeStbImage.stbi_set_flip_vertically_on_load(shouldFlip ? 1 : 0);
 }
Пример #6
0
 public static void ConvertIphonePngToRgb(bool shouldConvert)
 {
     NativeStbImage.stbi_convert_iphone_png_to_rgb(shouldConvert ? 1 : 0);
 }
Пример #7
0
 public static void SetUnpremultiplyOnLoad(bool shouldUnpremultiply)
 {
     NativeStbImage.stbi_set_unpremultiply_on_load(shouldUnpremultiply ? 1 : 0);
 }
Пример #8
0
 public static void ImageFree(void *image)
 {
     NativeStbImage.stbi_image_free(image);
 }
Пример #9
0
 public static string FailureReason()
 {
     return(Marshal.PtrToStringUTF8((IntPtr)NativeStbImage.stbi_failure_reason()));
 }
Пример #10
0
 public static void LdrToHdrScale(float scale)
 {
     NativeStbImage.stbi_ldr_to_hdr_scale(scale);
 }