/// <summary> /// Retorna o somatório dos tamanhos dos bitmaps anteriores ao do índice parametrizado. /// </summary> /// <param name="indice_bitmap">Indice do bitmap para o qual se deseja saber o offset.</param> /// <returns>Endereço do bitmap parametrizado.</returns> public UInt32 TamanhoBitmapAcumulado(int indice_bitmap) { unsafe { UInt32 resultado = (UInt32)sizeof(FormatoFonte); for (int i = 0; i < indice_bitmap; i++) { //result = result + this.bitmaps[i].tamanho; Byte[] pixelByte = bitmaps[i].FromMatrixToArray(); resultado = (UInt32)(resultado + pixelByte.Length + sizeof(uint)); } CaractereInfo ci = new CaractereInfo(); ci.codigo = (byte)(indice_bitmap + 32); ci.enderecoBitmap = resultado; this.caracteres[indice_bitmap] = ci; //for (int i = 0; i < indice_bitmap; i++) //{ // result = result + this.bitmaps[i].; //} return(resultado); } }
private void FromBytesToFormatoFonte(byte[] dados) { unsafe { fixed(byte *pSrc = dados) { FormatoFonte *formatoFonte = (FormatoFonte *)pSrc; this.Versao = formatoFonte->versao; this.Altura = formatoFonte->altura; this.flags = formatoFonte->flags; for (int i = 0; i < 49; i++) { this.nomeFonte[i] = formatoFonte->nomeFonte[i]; } this.crc = formatoFonte->crc; int indiceInfoCaractere = 0; this.caracteres.Clear(); //carrega as informações do cabeçalho de caracteres. for (int i = 0; i < 224; i++) { CaractereInfo c = new CaractereInfo(); CaractereInfo *caracteresInfo = ((CaractereInfo *)formatoFonte->caractereInfo); c.codigo = caracteresInfo[i].codigo; c.enderecoBitmap = caracteresInfo[i].enderecoBitmap; this.caracteres.Add(c); } } } //caracteres.Sort(delegate(CaractereInfo a, CaractereInfo b) // { // return a.codigo.CompareTo(b.codigo); // }); // Ordenar os caracteres pelo código, pois algumas fontes do Pontos 6 não estão em ordem caracteres.Sort((a, b) => a.codigo.CompareTo(b.codigo)); //carrega as informações sobre os bitmaps. this.bitmaps.Clear(); for (int bitmap = 0; bitmap < 224; bitmap++) { Bitmap b = new Bitmap(); b = CarregarBitmap(this.NomeArquivo, caracteres[bitmap].enderecoBitmap, bitmap); this.bitmaps.Add(b); } }
public Arquivo_FNT() { InicializaListaSizeBits(); //Versao = 1; reservado = new byte[3]; Altura = 8; reservado2 = new byte[4]; //byte 1: Italico; //byte 2: Negrito; //byte 3 em diante, reservado; flags = 0; nomeFonte = new byte[49]; crc = 0; //caractereInfo = new CaractereInfo[224]; caracteres = new List <CaractereInfo>(224); this.bitmaps = new List <Bitmap>(); unsafe { for (int i = 0; i < 224; i++) { CaractereInfo ci = new CaractereInfo(); ci.codigo = (byte)(i + 32); //ci.reservado = new byte[3]; //if (i == 0) // ci.enderecoBitmap = (UInt32)sizeof(FormatoFonte); //else // ci.enderecoBitmap = TamanhoBitmapAcumulado(i); this.caracteres.Add(ci); } } }