public override void Open() { Close(); Header = TimHeader.Read(IOStream); Palettes = TimPalettes.TryRead(Header, IOStream); }
public static TimHeader Read(Stream input) { TimHeader result = input.ReadStruct <TimHeader>(); result.Validate(); return(result); }
public static TimImageHeader Read(TimHeader header, Stream input) { TimImageHeader result = input.ReadStruct <TimImageHeader>(); if (header.BytesPerPixel == 0) { result.Width *= 2; } return(result); }
private static TimPalettes Read(TimHeader header, Stream input) { TimPalettesHeader palettesHeader = TimPalettesHeader.Read(input); BitmapPalette[] palettes = new BitmapPalette[palettesHeader.PalettesCount]; for (int i = 0; i < palettes.Length; i++) { palettes[i] = ReadPalette(palettesHeader, input); } return(new TimPalettes(palettesHeader, palettes)); }
public TimPixelFormatsConverter(TimHeader header, TimImageHeader imageHeader, Stream input, Stream output) { Exceptions.CheckArgumentNull(header, "header"); Exceptions.CheckArgumentNull(imageHeader, "imageHeader"); Exceptions.CheckArgumentNull(input, "input"); Exceptions.CheckArgumentNull(output, "output"); _header = header; _imageHeader = imageHeader; _input = input; _output = output; }
public static TimPalettes TryRead(TimHeader header, Stream input) { Exceptions.CheckArgumentNull(header, "header"); Exceptions.CheckArgumentNull(input, "input"); if (!header.HasPalette) { return(null); } return(Read(header, input)); }
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)); }
public TimTexture2DReader(TimHeader header, TimImageHeader imageHeader, Stream input) { _header = Exceptions.CheckArgumentNull(header, "header"); _imageHeader = Exceptions.CheckArgumentNull(imageHeader, "imageHeader"); _input = Exceptions.CheckReadableStream(input, "input"); }
public static GLTexture Read(TimHeader header, TimImageHeader imageHeader, Stream input) { TimTexture2DReader converter = new TimTexture2DReader(header, imageHeader, input); return(converter.Read()); }
public static void Convert(TimHeader header, TimImageHeader imageHeader, Stream input, Stream output) { TimPixelFormatsConverter converter = new TimPixelFormatsConverter(header, imageHeader, input, output); converter.Convert(); }
public override void Close() { IOStream.Seek(0, SeekOrigin.Begin); Header = null; Palettes = null; }