Beispiel #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));
        }
Beispiel #2
0
        public static void Convert(TimHeader header, TimImageHeader imageHeader, Stream input, Stream output)
        {
            TimPixelFormatsConverter converter = new TimPixelFormatsConverter(header, imageHeader, input, output);

            converter.Convert();
        }