public TGA(string fileName, byte[] data) : base(fileName, data) // used when importing file { // saving tga header data in TGAHeader structure GCHandle handle = GCHandle.Alloc(headData, GCHandleType.Pinned); TGAHeader = (_TGAHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(_TGAHeader)); handle.Free(); imgSize = new ImageSize((uint)TGAHeader.width, (uint)TGAHeader.height); BPP = TGAHeader.bits / 8; if (RLECompressed) { RLEDecompress(); // decompress } else { imgData = imgData.Take(TGAHeader.width * TGAHeader.height * (int)BPP).ToArray(); // get rid of tga footer } if (verticalFlipped) { flipVertically(); } format = subtype(); }
public TGA(string fileName, byte[] data) : base(fileName, data) // used when importing file { // saving tga header data in TGAHeader structure GCHandle handle = GCHandle.Alloc(headData, GCHandleType.Pinned); TGAHeader = (_TGAHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(_TGAHeader)); handle.Free(); imgSize = new ImageSize((uint)TGAHeader.width, (uint)TGAHeader.height); BPP = TGAHeader.bits / 8; if (RLECompressed) RLEDecompress(); // decompress else imgData = imgData.Take(TGAHeader.width * TGAHeader.height * (int)BPP).ToArray(); // get rid of tga footer if (verticalFlipped) flipVertically(); format = subtype(); }