예제 #1
0
파일: File.cs 프로젝트: And-G/Magellan
		protected File() {
			numchannels = 0;
			imgsize = Size.Empty;
			bpp = 8;
			mode = ImageMode.RGBColor;
			colormap = new Colormap();
			resources = new Resources();
			layers = new Layers( this );
			image = null;
		}
예제 #2
0
파일: File.cs 프로젝트: And-G/Magellan
		public void ReadFrom( BinaryReader reader ) {
			ReadHeader( reader );
			colormap = new Colormap( reader );
			resources = new Resources( reader );
			layers = new Layers( this, reader );

			CompressionMethod compression = (CompressionMethod)IPAddress.NetworkToHostOrder( reader.ReadInt16() );
			byte[][] data = new byte[3][];
			switch ( compression ) {
				case CompressionMethod.Raw:
					// read each line
 
					for ( int c=0; c<3; c++ ) {
						//data[c] = new byte[imgsize.Width*imgsize.Height];
						//int i = 0;
						//while ( i < imgsize.Width*imgsize.Height ) i += reader.Read( data[c], i, (imgsize.Width*imgsize.Height)-i );
						data[c] = new byte[imgsize.Width*imgsize.Height];
						reader.Read( data[c], 0, data[c].Length );
					}
					image = new Channels( imgsize, data[0], data[1], data[2] ).Combine();
					break;

				case CompressionMethod.RLE:
					// Throw widthlist away...
					reader.ReadBytes( imgsize.Height * numchannels  * 2 );

					// read each line
					for ( int c=0; c<3; c++ ) {
						data[c] = new byte[imgsize.Width*imgsize.Height];
						for ( int y=0, offset = 0; y<imgsize.Height; ++y ) {
							offset += Utils.UnpackRLELine( reader, imgsize.Width, data[c], offset );
						}
					}
					image = new Channels( imgsize, data[0], data[1], data[2] ).Combine();

					break;
				default:
					throw new InvalidCompressionMethodException( compression );
			}
		}