Exemplo n.º 1
0
        public static TimImage Read(TimHeader header, Stream input)
        {
            TimImageHeader imageHeader = TimImageHeader.Read(header, input);
            GLTexture      layer       = TimTexture2DReader.Read(header, imageHeader, input);

            //SafeHGlobalHandle pixels = new SafeHGlobalHandle(imageHeader.Width * imageHeader.Height * header.OutputPixelFormat.BitsPerPixel / 8);
            SafeHGlobalHandle pixels = new SafeHGlobalHandle(imageHeader.ContentSize);

            try
            {
                using (UnmanagedMemoryStream output = new UnmanagedMemoryStream(pixels, 0, (long)pixels.ByteLength, FileAccess.Write))
                    TimPixelFormatsConverter.Convert(header, imageHeader, input, output);
            }
            catch
            {
                pixels.Dispose();
                throw;
            }
            return(new TimImage(imageHeader, layer));
        }
Exemplo n.º 2
0
        public static GLTexture Read(TimHeader header, TimImageHeader imageHeader, Stream input)
        {
            TimTexture2DReader converter = new TimTexture2DReader(header, imageHeader, input);

            return(converter.Read());
        }