Beispiel #1
0
        protected override void ParseData(byte[] chunkData)
        {
            Llista <byte> bytesAConvertir = new Llista <byte>();
            Encoding      encodingSource  = null;
            long          posicion        = 0;

            while (chunkData[posicion] != NULLBYTE && chunkData.LongLength > posicion)
            {
                bytesAConvertir.Add(chunkData[posicion++]);
            }
            if (chunkData[posicion] == NULLBYTE)
            {
                keyword = Serializar.ToString(bytesAConvertir.ToTaula());
                bytesAConvertir.Clear();
                posicion++;                              //paso el Null byte
                if (COMPRESION != chunkData[posicion++]) //leo la compresion
                {
                    throw new ChunkFormatException();
                }
                while (chunkData.LongLength > posicion)
                {
                    bytesAConvertir.Add(chunkData[posicion++]);
                }
                encodingSource = System.Text.Encoding.GetEncoding(1252);                //es la unica usada...
                Information    = Serializar.ToString(System.Text.ASCIIEncoding.Convert(encodingSource, Encoding.ASCII, bytesAConvertir.ToTaula()));
            }
            else
            {
                throw new ChunkFormatException();
            }
        }
Beispiel #2
0
        protected override void ParseData(byte[] chunkData)
        {
            Llista <byte> bytesAConvertir = new Llista <byte>();
            long          posicion        = 0;

            while (chunkData[posicion] != NULLBYTE && chunkData.LongLength > posicion)
            {
                bytesAConvertir.Add(chunkData[posicion++]);
            }
            if (chunkData[posicion] == NULLBYTE)
            {
                keyword = Serializar.ToString(bytesAConvertir.ToTaula());
                bytesAConvertir.Clear();
                posicion++;                //paso nullByte
                while (chunkData.LongLength > posicion)
                {
                    bytesAConvertir.Add(chunkData[posicion++]);
                }
                Information = Serializar.ToString(System.Text.ASCIIEncoding.Convert(System.Text.Encoding.GetEncoding(1252), Encoding.ASCII, bytesAConvertir.ToTaula()));
            }
            else
            {
                throw new ChunkFormatException();
            }
        }
Beispiel #3
0
        protected virtual void UpdateData()
        {
            Llista <Byte> data = new Llista <byte>();

            data.AddRange(Serializar.GetBytes(Keyword));                                                                                                //Keyword
            data.Add(NULLBYTE);                                                                                                                         //null separator
            data.Add(COMPRESION);
            data.AddRange(System.Text.ASCIIEncoding.Convert(Encoding.ASCII, System.Text.Encoding.GetEncoding(1252), Serializar.GetBytes(Information))); //text
            ChunkData = data.ToTaula();
        }
Beispiel #4
0
        void Update()
        {
            Llista <byte> dataBytes = new Llista <byte>();

            dataBytes.AddRange(Serializar.GetBytes(SequenceNumber));
            dataBytes.AddRange(Serializar.GetBytes(Width));
            dataBytes.AddRange(Serializar.GetBytes(Height));
            dataBytes.AddRange(Serializar.GetBytes(OffsetX));
            dataBytes.AddRange(Serializar.GetBytes(OffsetY));
            dataBytes.AddRange(Serializar.GetBytes(DelayNum));
            dataBytes.AddRange(Serializar.GetBytes(DelayDen));
            dataBytes.Add((byte)DisposeOP);
            dataBytes.Add((byte)BlendOP);
            ChunkData = dataBytes.ToTaula();
        }
Beispiel #5
0
 public static void AñadirFaena(Tiket <TipoTrabajo> tiket)
 {
     tiket.DentroPool = true;
     faenasEstaticas.Add(tiket);
     if (estaOrdenado)
     {
         faenasEstaticas.Sort();
     }
 }
        public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator()
        {
            Llista <KeyValuePair <TKey, TValue> > parelles = new Llista <KeyValuePair <TKey, TValue> >();

            Monitor.Enter(llistaOrdenada);
            for (int i = 0; i < llista.Count; i++)
            {
                parelles.Add(new KeyValuePair <TKey, TValue>(llista[i], llistaOrdenada[llista[i]]));
            }
            Monitor.Exit(llistaOrdenada);
            return(parelles.GetEnumerator());
        }
Beispiel #7
0
        public void AddFrame(Bitmap bmp, int delay = 500, int posicion = -1)
        {
            if (bmp == null || delay < 0)
            {
                throw new ArgumentException();
            }

            KeyValuePair <Bitmap, int> frame = new KeyValuePair <Bitmap, int>(bmp, delay);

            if (posicion < 0 || posicion > frames.Count)
            {
                frames.Add(frame);
            }
            else
            {
                frames.Insert(posicion, frame);
            }
        }
Beispiel #8
0
        public Chunk[] GetChunks()
        {
            Llista <Chunk> chunks    = new Llista <Chunk>();
            Chunk          chunkIDAT = null;
            uint           orden     = 3;//no se porque va de 3 en 3....

            if (pngs.Count > 0)
            {
                //	pngs.Ordena();
                chunks.Add(IhdrChunk);                                             //IHDR
                chunks.Add(new acTLChunk(NumeroDeRepeticiones, (uint)pngs.Count)); //acTL

                //pongo los pngs
                //fcTL
                if (!SaltarPrimerFotograma)
                {
                    pngs[0].FCTL.SequenceNumber = orden; orden += 3;
                    chunks.Add(pngs[0].FCTL);
                }
                //Idata
                for (int j = 0; j < pngs[0].IDATS.Count; j++)
                {
                    pngs[0].IDATS[j].ChunkType = IDATChunk.NAME;//el primero es IDAT
                    chunks.Add(pngs[0].IDATS[j]);
                }
                for (int i = 1; i < pngs.Count; i++)
                {
                    //fcTL

                    pngs[i].FCTL.SequenceNumber = orden; orden += 3;
                    chunks.Add(pngs[i].FCTL);
                    //Idata
                    for (int j = 0; j < pngs[i].IDATS.Count; j++)
                    {
                        chunkIDAT           = pngs[i].IDATS[j].Clon();
                        chunkIDAT.ChunkType = fdATChunk.NAME;// los demás fdAT
                        chunks.Add(chunkIDAT);
                    }
                }
                chunks.AddRange(metadata);
                chunks.Add(IendChunk);
            }
            return(chunks.ToTaula());
        }
Beispiel #9
0
        public BitmapAnimated(IList <Bitmap> bmps, params int[] delays)
        {
            int i = 0;

            numeroDeRepeticionesFijas = 1;
            frameAlAcabar             = 0;
            animarCiclicamente        = true;
            frames = new Llista <KeyValuePair <Bitmap, int> >();
            if (bmps != null)
            {
                for (int j = 0; j < bmps.Count; j++)
                {
                    frames.Add(new KeyValuePair <Bitmap, int>(bmps[j], delays[i]));
                    if (delays.Length > i)
                    {
                        i++;
                    }
                }
            }
        }
Beispiel #10
0
        public void Add(Chunk chunk, bool reemplazarOExcepcion)
        {
            Chunk chunkABuscar = null;

            switch (chunk.ChunkType)
            {
            case IDATChunk.NAME:
                idats.Add(chunk);
                break;

            case "iCCP":
                if (sRGB != null)
                {
                    if (reemplazarOExcepcion)
                    {
                        sRGB = null;
                    }
                    else
                    {
                        throw new Exception("Ya existe un chunk sRGB por lo que no puede ir un iCCP");
                    }
                }
                if (iCCP != null)
                {
                    if (!reemplazarOExcepcion)
                    {
                        throw new Exception("Chunk " + chunk.ChunkType + " repetido...solo puede haber uno");
                    }
                }
                iCCP = chunk;
                break;

            case "sRGB":
                if (iCCP != null)
                {
                    if (reemplazarOExcepcion)
                    {
                        iCCP = null;
                    }
                    else
                    {
                        throw new Exception("Ya existe un chunk iCCP por lo que no puede ir un sRGB");
                    }
                }
                if (sRGB != null)
                {
                    if (!reemplazarOExcepcion)
                    {
                        throw new Exception("Chunk " + chunk.ChunkType + " repetido...solo puede haber uno");
                    }
                }
                sRGB = chunk;
                break;

            case tIMEChunk.NAME:
                if (tIME != null && !reemplazarOExcepcion)
                {
                    throw new Exception("Solo puede haber un chunk tIME!!");
                }
                tIME = new tIMEChunk(chunk);
                break;

            case "PLTE":
                if (PLTE != null && !reemplazarOExcepcion)
                {
                    throw new Exception("Solo puede haber un chunk PLTE!!");
                }
                PLTE = chunk;
                break;

            case tEXtChunk.NAME:
                tEXtChunk tEXt = new tEXtChunk(chunk);
                metadata.Add(tEXt.Keyword, tEXt);
                break;

            case zTXtChunk.NAME:
                zTXtChunk zTXt = new zTXtChunk(chunk);
                metadata.Add(zTXt.Keyword, zTXt);
                break;

            default:
                if (!chunksCeroOIlimitados.Existe(chunk.ChunkType))
                {
                    //miro si existe
                    extras.WhileEach(chunkToCompare => {
                        if (chunkToCompare.Equals(chunk))
                        {
                            chunkABuscar = chunk;
                        }
                        return(chunkABuscar == null);
                    });
                    //si existe lo trato
                    if (chunkABuscar != null)
                    {
                        if (reemplazarOExcepcion)
                        {
                            extras.Remove(chunkABuscar);
                        }
                        else
                        {
                            throw new Exception("Solo puede haber uno de " + chunkABuscar);
                        }
                    }
                }
                extras.Add(chunk);
                break;
            }
        }
Beispiel #11
0
 public void Add(T item)
 {
     pila.Add(item);
 }