Exemplo n.º 1
0
        /**
         * this should be called only for ancillary chunks and PLTE (groups 1 - 3 - 5)
         **/
        private static bool shouldWrite(PngChunk c, int currentGroup)
        {
            if (currentGroup == CHUNK_GROUP_2_PLTE)
            {
                return(c.Id.Equals(ChunkHelper.PLTE));
            }
            if (currentGroup % 2 == 0)
            {
                throw new PngjOutputException("bad chunk group?");
            }
            int minChunkGroup, maxChunkGroup;

            if (c.mustGoBeforePLTE())
            {
                minChunkGroup = maxChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR;
            }
            else if (c.mustGoBeforeIDAT())
            {
                maxChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE;
                minChunkGroup = c.mustGoAfterPLTE() ? ChunksList.CHUNK_GROUP_3_AFTERPLTE
                        : ChunksList.CHUNK_GROUP_1_AFTERIDHR;
            }
            else
            {
                maxChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT;
                minChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR;
            }

            int preferred = maxChunkGroup;

            if (c.Priority)
            {
                preferred = minChunkGroup;
            }
            if (ChunkHelper.IsUnknown(c) && c.ChunkGroup > 0)
            {
                preferred = c.ChunkGroup;
            }
            if (currentGroup == preferred)
            {
                return(true);
            }
            if (currentGroup > preferred && currentGroup <= maxChunkGroup)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public static bool shouldWrite(PngChunk c, int currentGroup)
        {
            if (currentGroup == 2)
            {
                return(c.Id.Equals("PLTE"));
            }
            if (currentGroup % 2 == 0)
            {
                throw new PngjOutputException("bad chunk group?");
            }
            int num2;
            int num;

            if (c.mustGoBeforePLTE())
            {
                num2 = (num = 1);
            }
            else if (c.mustGoBeforeIDAT())
            {
                num  = 3;
                num2 = ((!c.mustGoAfterPLTE()) ? 1 : 3);
            }
            else
            {
                num  = 5;
                num2 = 1;
            }
            int num3 = num;

            if (c.Priority)
            {
                num3 = num2;
            }
            if (ChunkHelper.IsUnknown(c) && c.ChunkGroup > 0)
            {
                num3 = c.ChunkGroup;
            }
            if (currentGroup == num3)
            {
                return(true);
            }
            if (currentGroup > num3 && currentGroup <= num)
            {
                return(true);
            }
            return(false);
        }