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(); } }
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(); } }
protected virtual void UpdateData() { Llista <Byte> data = new Llista <byte>(); data.AddRange(Serializar.GetBytes(Keyword)); //Keyword data.Add(NULLBYTE); //null separator data.AddRange(System.Text.ASCIIEncoding.Convert(Encoding.ASCII, System.Text.Encoding.GetEncoding(1252), Serializar.GetBytes(Information))); //text ChunkData = data.ToTaula(); }
protected override void ParseData(byte[] chunkData) { if (chunkData.Length != 7) { throw new ArgumentException(); } fecha = new DateTime((int)Serializar.ToShort(new byte[] { chunkData[1], chunkData[0] }), (int)chunkData[2], (int)chunkData[3], (int)chunkData[4], (int)chunkData[5], (int)chunkData[6]).ToLocalTime(); }
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(); }
void UpDateData() { DateTime fecha = this.fecha.ToUniversalTime(); byte[] bytesAño = Serializar.GetBytes((short)fecha.Year); ChunkData = new byte[] { bytesAño[1], bytesAño[0], (byte)fecha.Month, (byte)fecha.Day, (byte)fecha.Hour, (byte)fecha.Minute, (byte)fecha.Second }; }
public Point GetPoint(int colorInt) { const int ARGB = 4; int posicion; byte[] bytesColor; Point location = default(Point); bool encontrado = false; if (pointLocatedByColorList.ContainsKey(colorInt)) { location = pointLocatedByColorList[colorInt].Value; } else { bytesColor = Serializar.GetBytes(colorInt); for (int y = 0, yFin = Convert.ToInt32(imagen.Height), xFin = Convert.ToInt32(imagen.Width) * ARGB; y < yFin && !encontrado; y++) { for (int x = 0; x < xFin && !encontrado; x += ARGB) { posicion = x + (y * xFin); encontrado = bytesImg[posicion] == bytesColor[0] && bytesImg[posicion + 1] == bytesColor[1] && bytesImg[posicion + 2] == bytesColor[2] && bytesImg[posicion + 3] == bytesColor[3]; if (encontrado) { location = new Point(x, y); } } } if (!encontrado) { throw new ArgumentOutOfRangeException("El color no esta dentro de la imagen!"); } else { pointLocatedByColorList.Add(colorInt, location); if (!colorLocatedByPointerList.ContainsKey(new PointZ(location, 0))) { colorLocatedByPointerList.Add(new PointZ(location, 0), System.Drawing.Color.FromArgb(colorInt)); } } } return(location); }
protected override void ParseData(byte[] chunkData) { if (chunkData != null && chunkData.Length < 26) { throw new ArgumentException(); } int offset = 0; sequenceNumber = Utils.ParseUint(chunkData, 4, ref offset); width = Utils.ParseUint(chunkData, 4, ref offset); height = Utils.ParseUint(chunkData, 4, ref offset); offsetX = Utils.ParseUint(chunkData, 4, ref offset); offsetY = Utils.ParseUint(chunkData, 4, ref offset); delayNum = Serializar.ToUShort(new byte[] { chunkData[21], chunkData[20] }); delayDen = Serializar.ToUShort(new byte[] { chunkData[23], chunkData[22] }); disposeOP = (Dispose)chunkData[24]; blendOP = (Blend)chunkData[25]; }
void UpDate() { Llista <byte> dataBytes = new Llista <byte>(); uint[] fields = { width, height, bitDepth, colorType, compressionMethod, filterMethod, interlaceMethod }; for (int i = 0; i < fields.Length; i++) { dataBytes.AddRange(Serializar.GetBytes(fields[i])); } ChunkData = dataBytes.ToTaula(); }
void UpdateData() { ChunkData = Serializar.GetBytes(NumeroDeFotogramas).AfegirValors(Serializar.GetBytes(NumeroDeRepeticiones)).ToTaula(); }