Пример #1
0
        public static ProtoLayer FromLayer( Layer source )
        {
            ProtoLayer result = new ProtoLayer();

            result.name = source.Name;
            result.bounds = source.Bounds;
            result.opacity = source.Opacity;
            result.visible = source.Visible;
            result.protecttrans = source.ProtectTransparancy;
            result.clipping = source.Clipping;
            result.blendkey = source.Mode.Key;
            result.channels = Channels.FromImage( source.Image );

            return result;
        }
Пример #2
0
        private void WriteLayers( BinaryWriter writer )
        {
            int layercount = items.Length;
            writer.Write( IPAddress.HostToNetworkOrder( (short)(absolutealpha ? -layercount : layercount) ) );

            ProtoLayer[] protolayers = new ProtoLayer[layercount];
            for ( int i=0; i<layercount; ++i ) {
                protolayers[i] = ProtoLayer.FromLayer( items[i] );
                protolayers[i].WriteDefinitionTo( writer );
            }

            for ( int i=0; i<layercount; ++i ) {
                protolayers[i].WritePixelDataTo( writer );
            }
        }
Пример #3
0
        public static Layer FromProtoLayer( ProtoLayer proto, File file )
        {
            Layer result = new Layer( file );
            result.name = proto.Name;
            result.location = proto.Bounds.Location;
            result.clipping = proto.Clipping;
            result.visible = proto.Visible;
            result.opacity = proto.Opacity;
            result.protecttrans = proto.ProtectTransparancy;
            result.image = proto.BuildImage();
            result.mode = LayerMode.FromKey( proto.Blendkey );
            result.mask = proto.BuildMask();
            result.adjustments = new LayerAdjustment[proto.Adjustments.Length];
            proto.Adjustments.CopyTo( result.adjustments, 0 );

            return result;
        }
Пример #4
0
        private void ReadLayers( BinaryReader reader )
        {
            int layercount = IPAddress.NetworkToHostOrder( reader.ReadInt16() );

            if ( layercount < 0 ) {
                layercount = -layercount;
                absolutealpha = true;
            }
            else {
                absolutealpha = false;
            }

            ProtoLayer[] protolayers = new ProtoLayer[layercount];
            for ( int i=0; i<layercount; ++i ) {
                protolayers[i] = new ProtoLayer();
                protolayers[i].ReadDefinitionFrom( reader );
            }

            // Read layer data nadProtolayers to real layers
            items = new Layer[protolayers.Length];
            for ( int i=0; i<protolayers.Length; ++i ) {
                protolayers[i].ReadPixelDataFrom( reader );
                items[i] = Layer.FromProtoLayer( protolayers[i], file );
            }
        }