private StciRgb LoadStciRgb(BinaryReader aReader, Ja2Data.StciHeader aHeader) { StciRgb _newStciRgb = new StciRgb(); Ja2Data.StciRgb _stciRgb = new Ja2Data.StciRgb(aHeader); Ja2Data.StciRgbHeader _subHeader = (Ja2Data.StciRgbHeader)_stciRgb.Header.SubHeader; _newStciRgb.AlphaDepth = _subHeader.AlphaDepth; _newStciRgb.AlphaMask = (int)_subHeader.AlphaMask; _newStciRgb.BlueDepth = _subHeader.BlueDepth; _newStciRgb.BlueMask = (int)_subHeader.BlueMask; _newStciRgb.GreenDepth = _subHeader.GreenDepth; _newStciRgb.GreenMask = (int)_subHeader.GreenMask; _newStciRgb.RedDepth = _subHeader.RedDepth; _newStciRgb.RedMask = (int)_subHeader.RedMask; _newStciRgb.DateCreated = DateTime.Now; _newStciRgb.UserId = this.FUserId; int _imageSize = (int)_stciRgb.Header.OriginalImageSize; UnstructuredData _data = new UnstructuredData(); _data.Data = aReader.ReadBytes(_imageSize); _data.UserId = this.FUserId; _data.DateCreated = DateTime.Now; this.FUnstructuredData.Add(_data); _newStciRgb.UnstructuredData = _data; return(_newStciRgb); }
private SlfRecordStci LoadStciHeader(Ja2Data.StciHeader aStciHeader) { SlfRecordStci _newStciHeader = new SlfRecordStci(); _newStciHeader.AppDataSize = (int)aStciHeader.AppDataSize; _newStciHeader.Depth = aStciHeader.Depth; _newStciHeader.Height = aStciHeader.ImageHeight; _newStciHeader.ID = aStciHeader.FormatId; _newStciHeader.OriginalSize = aStciHeader.OriginalImageSize; _newStciHeader.StoredSize = aStciHeader.CompressedImageSize; _newStciHeader.TransparentValue = aStciHeader.TransparentColorIndex; _newStciHeader.Unused = aStciHeader.Unused; _newStciHeader.Width = aStciHeader.ImageWidth; _newStciHeader.UserId = this.FUserId; _newStciHeader.DateCreated = DateTime.Now; var _flags = this.FStciFlags.Where(x => (x.Mask & (byte)aStciHeader.Flags) != 0); foreach (Flag _flag in _flags) { StciRecordStciFlag _recFlag = new StciRecordStciFlag(); _recFlag.FlagId = (byte)_flag.Id; _recFlag.SlfRecordStci = _newStciHeader; this.FRecordsFlags.Add(_recFlag); } return(_newStciHeader); }
private StciIndexed LoadStciIndexed(BinaryReader aReader, Ja2Data.StciHeader aHeader) { StciIndexed _newStciIndexed = new StciIndexed(); Ja2Data.StciIndexed _stciIndexed = new Ja2Data.StciIndexed(aHeader); _stciIndexed.Load(aReader); Ja2Data.StciIndexedHeader _subHeader = (Ja2Data.StciIndexedHeader)aHeader.SubHeader; _newStciIndexed.BlueDepth = _subHeader.BlueDepth; _newStciIndexed.GreenDepth = _subHeader.GreenDepth; _newStciIndexed.NumberOfColours = _subHeader.NumberOfColous; _newStciIndexed.NumberOfSubImages = (int)_subHeader.NumberOfSubImages; _newStciIndexed.RedDepth = _subHeader.RedDepth; _newStciIndexed.Unused = _subHeader.Unused; _newStciIndexed.DateCreated = DateTime.Now; _newStciIndexed.UserId = this.FUserId; _newStciIndexed.Palette = _stciIndexed.Palette; for (int i = 0; i < _subHeader.NumberOfSubImages; i++) { StciIndexedSubImage _subImage = this.LoadSubImage(_stciIndexed.Images[i]); _subImage.StciIndexed = _newStciIndexed; this.FSubImages.Add(_subImage); } return(_newStciIndexed); }
private byte[] DownloadStiIndexed(SlfRecordStci aStciRecord, int aDataLength) { Ja2Data.StciHeader _header = DownloadStciHeader(aStciRecord); StciIndexed _indexedRec = aStciRecord.StciIndexed.First(); Ja2Data.StciIndexedHeader _subHeader = new Ja2Data.StciIndexedHeader((UInt16)_indexedRec.NumberOfSubImages); _subHeader.BlueDepth = _indexedRec.BlueDepth; _subHeader.GreenDepth = _indexedRec.GreenDepth; _subHeader.RedDepth = _indexedRec.RedDepth; _subHeader.NumberOfColous = (uint)_indexedRec.NumberOfColours; _header.SubHeader = _subHeader; Ja2Data.StciSubImage[] _subImages = new Ja2Data.StciSubImage[_indexedRec.NumberOfSubImages]; int i = 0; foreach (StciIndexedSubImage _subImage in _indexedRec.StciIndexedSubImage) { _subImages[i] = this.DownloadStciSubimage(_subImage); i++; } Ja2Data.StciIndexed _stciIndexed = new Ja2Data.StciIndexed(_header, _indexedRec.Palette, _subImages); byte[] _buffer = new byte[aDataLength]; using (MemoryStream _ms = new MemoryStream(_buffer)) { _stciIndexed.Save(_ms); } return(_buffer); }
private byte[] DownloadStciRgb(SlfRecordStci aStciRecord, int aDataLength) { Ja2Data.StciHeader _header = DownloadStciHeader(aStciRecord); StciRgb _rgbRec = aStciRecord.StciRgb.First(); Ja2Data.StciRgbHeader _subHeader = new Ja2Data.StciRgbHeader(); _subHeader.AlphaDepth = _rgbRec.AlphaDepth; _subHeader.AlphaMask = (uint)_rgbRec.AlphaMask; _subHeader.BlueDepth = _rgbRec.BlueDepth; _subHeader.BlueMask = (uint)_rgbRec.BlueMask; _subHeader.GreenDepth = _rgbRec.GreenDepth; _subHeader.GreenMask = (uint)_rgbRec.GreenMask; _subHeader.RedDepth = _rgbRec.RedDepth; _subHeader.RedMask = (uint)_rgbRec.RedMask; _header.SubHeader = _subHeader; Ja2Data.StciRgb _stciRgb = new Ja2Data.StciRgb(_header); _stciRgb.ImageData = _rgbRec.UnstructuredData.Data; byte[] _buffer = new byte[aDataLength]; using (MemoryStream _ms = new MemoryStream(_buffer)) { _stciRgb.Save(_ms); } return(_buffer); }
public override int Upload(BinaryReader aReader, int aSlfFileId) { int _count = 0; foreach (Ja2Data.SlfFile.Record _file in this.FFiles) { try { aReader.BaseStream.Position = _file.Offset; SlfRecordHeader _recHeader = this.CreateSlfRecordHeader(_file); this.FHeaders.Add(_recHeader); Ja2Data.StciHeader _stciHeader = new Ja2Data.StciHeader(); _stciHeader.Read(aReader); SlfRecordStci _stciRecord = this.LoadStciHeader(_stciHeader); _stciRecord.SlfRecordHeader = _recHeader; _stciRecord.SlfFileId = aSlfFileId; this.FRecords.Add(_stciRecord); if (_stciHeader.IsIndexed) { StciIndexed _newStciIndexed = this.LoadStciIndexed(aReader, _stciHeader); _newStciIndexed.SlfRecordStci = _stciRecord; this.FRecordsIndexed.Add(_newStciIndexed); } else { StciRgb _newStciRgb = this.LoadStciRgb(aReader, _stciHeader); _newStciRgb.SlfRecordStci = _stciRecord; this.FRecordsRgb.Add(_newStciRgb); } this.AddRecordsToDataSet(); _count += this.SaveChanges(); } catch (Exception _exc) { string _excMess = String.Format("Uploading file {0} exception\n", _file.FileName); throw new Exception(_excMess, _exc); } } return(_count); }
private static Ja2Data.StciHeader DownloadStciHeader(SlfRecordStci aStciRecord) { Ja2Data.StciHeader _header = new Ja2Data.StciHeader(); _header.AppDataSize = (uint)aStciRecord.AppDataSize; _header.CompressedImageSize = aStciRecord.StoredSize; _header.Depth = aStciRecord.Depth; int _flags = 0; foreach (StciRecordStciFlag _flag in aStciRecord.StciRecordStciFlag) { _flags |= _flag.StciFlags.Mask.Value; } _header.Flags = (Ja2Data.StciFlags)_flags; _header.ImageHeight = aStciRecord.Height; _header.ImageWidth = aStciRecord.Width; _header.TransparentColorIndex = aStciRecord.TransparentValue; _header.OriginalImageSize = (uint)aStciRecord.OriginalSize; _header.Unused = aStciRecord.Unused; return(_header); }