Example #1
0
        public static T CloneChunk <T>(T chunk, ImageInfo info) where T : PngChunk
        {
            PngChunk pngChunk = FactoryFromId(chunk.Id, info);

            if ((object)pngChunk.GetType() != chunk.GetType())
            {
                throw new PngjException("bad class cloning chunk: " + pngChunk.GetType()?.ToString() + " " + chunk.GetType()?.ToString());
            }
            pngChunk.CloneDataFromRead(chunk);
            return((T)pngChunk);
        }
Example #2
0
        /* @SuppressWarnings("unchecked")*/
        public static T CloneChunk <T>(T chunk, ImageInfo info) where T : PngChunk
        {
            PngChunk cn = FactoryFromId(chunk.Id, info);

            if ((Object)cn.GetType() != (Object)chunk.GetType())
            {
                throw new PngjException("bad class cloning chunk: " + cn.GetType() + " "
                                        + chunk.GetType());
            }
            cn.CloneDataFromRead(chunk);
            return((T)cn);
        }