Пример #1
0
        public static AseChunk ReadChunk(AseFrame frame, ChunkType type, int size, AseReader reader)
        {
            var      pos   = reader.Position;
            AseChunk chunk = null;

            switch (type)
            {
            // Chunk types we care about
            case ChunkType.Palette:
                chunk = new AsePaletteChunk(frame, reader);
                break;

            case ChunkType.Layer:
                chunk = new AseLayerChunk(frame, reader);
                break;

            case ChunkType.Cel:
                chunk = new AseCelChunk(frame, reader, size);
                break;

            case ChunkType.ColorProfile:
                chunk = new AseColorProfileChunk(frame, reader);
                break;

            case ChunkType.FrameTags:
                chunk = new AseFrameTagsChunk(frame, reader);
                break;

            case ChunkType.Slice:
                chunk = new AseSliceChunk(frame, reader);
                break;

            case ChunkType.UserData:
                chunk = new AseUserDataChunk(frame, reader);
                break;

            // Chunk types we don't care about
            case ChunkType.OldPalette:
                chunk = new AseDummyChunk(frame, reader, type, size);
                break;

            // Chunk types we haven't handled yet. Indicates a bug that should be fixed.
            default:
                chunk = new AseDummyChunk(frame, reader, type, size);
                Debug.LogErrorFormat("Unhandled chunk type: {0}", ((ushort)type).ToString("X4"));
                break;
            }

            // Check that we read the right amount of bytes
            Assert.IsTrue((reader.Position - pos) == size, string.Format("Chunk {0} read {1} bytes but we were expected {2} bytes read", type, reader.Position - pos, size));
            reader.LastChunk = chunk;

            return(chunk);
        }
Пример #2
0
        private Func <uint, uint, int, uint> GetBlendFunc(AseLayerChunk layer)
        {
            switch (layer.BlendMode)
            {
            case BlendMode.Normal:
                return(Blender.rgba_blender_normal);

            case BlendMode.Darken:
                return(Blender.rgba_blender_darken);

            case BlendMode.Multiply:
                return(Blender.rgba_blender_multiply);

            case BlendMode.ColorBurn:
                return(Blender.rgba_blender_color_burn);

            case BlendMode.Lighten:
                return(Blender.rgba_blender_lighten);

            case BlendMode.Screen:
                return(Blender.rgba_blender_screen);

            case BlendMode.ColorDodge:
                return(Blender.rgba_blender_color_dodge);

            case BlendMode.Addition:
                return(Blender.rgba_blender_addition);

            case BlendMode.Overlay:
                return(Blender.rgba_blender_overlay);

            case BlendMode.SoftLight:
                return(Blender.rgba_blender_soft_light);

            case BlendMode.HardLight:
                return(Blender.rgba_blender_hard_light);

            case BlendMode.Difference:
                return(Blender.rgba_blender_difference);

            case BlendMode.Exclusion:
                return(Blender.rgba_blender_exclusion);

            case BlendMode.Subtract:
                return(Blender.rgba_blender_subtract);

            case BlendMode.Divide:
                return(Blender.rgba_blender_divide);

            case BlendMode.Hue:
                return(Blender.rgba_blender_hsl_hue);

            case BlendMode.Saturation:
                return(Blender.rgba_blender_hsl_saturation);

            case BlendMode.Color:
                return(Blender.rgba_blender_hsl_color);

            case BlendMode.Luminosity:
                return(Blender.rgba_blender_hsl_luminosity);

            default:
                Debug.LogErrorFormat("Unsupported blend mode: {0}", layer.BlendMode);
                return(Blender.rgba_blender_normal);
            }
        }
Пример #3
0
 public void VisitLayerChunk(AseLayerChunk layer)
 {
     m_Layers.Add(layer);
 }