public unsafe void SaveImages() { fixed(byte *pImg = &this.file.image[0]) { indexSubTableArray *subtableB = (indexSubTableArray *)(pImg + (uint)entry.offset + (uint)size.indexSubTableArrayOffset); indexSubTableArray *subtableM = subtableB + (uint)size.numberOfIndexSubTables; indexSubTableArray *subtable = subtableB; indexSubHeader * subheader; //----- System.Drawing.Bitmap bmp; System.Drawing.Bitmap bmp0 = new System.Drawing.Bitmap(300, 300); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp0); g.Clear(System.Drawing.Color.Gray); int x = 0, y = 0; //----- while (subtable < subtableM) { subheader = (indexSubHeader *)((byte *)subtableB + (uint)subtable->additionalOffsetToIndexSubTable); if ((ushort)subheader->indexFormat == 1 && (ushort)subheader->imageFormat == 7) { indexSubTable1 *table = (indexSubTable1 *)subheader; ULONG * offset = &table->offsetArray; ULONG * offsetM = offset + ((ushort)subtable->lastGlyphIndex - (ushort)subtable->firstGlyphIndex + 1); byte * imageDataOffset = pImg + (uint)this.file.tables["EBDT"].offset + (uint)subheader->imageDataOffset; while (offset < offsetM) { ebdtFormat7 *f7 = (ebdtFormat7 *)(imageDataOffset + (uint)*offset); g.DrawImageUnscaled(bmp = f7->GetBitmap(), x, y); bmp.Dispose(); offset++; x += 10; if (x >= 300) { x = 0; y += 10; } } } subtable++; } //----- g.Dispose(); System.Drawing.Bitmap bmp1 = afh.Drawing.BitmapEffect.Invert(bmp0); bmp0.Dispose(); bmp1.Save(System.IO.Path.Combine(afh.Application.Path.ExecutableDirectory, "images\\" + this.Text + ".bmp")); bmp1.Dispose(); //----- } }
public unsafe void SetStrike(TTFFile file, TableDirectoryEntry entry, bitmapSizeTable size) { this.file = file; this.entry = entry; this.size = size; this.horiLineMetrics.SetLineMetrics(size.hori); this.vertLineMetrics.SetLineMetrics(size.vert); // set text to labels this.lStartGlyphIndex.Text = "0x" + ((uint)this.size.startGlyphIndex).ToString("X4"); this.lEndGlyphIndex.Text = "0x" + ((uint)this.size.endGlyphIndex).ToString("X4"); this.lPpemX.Text = this.size.ppemX.ToString(); this.lPpemY.Text = this.size.ppemY.ToString(); this.lBitDepth.Text = this.size.bitDepth.ToString(); this.lColorRef.Text = "0x" + ((uint)this.size.colorRef).ToString("X8"); this.pictColorRef.BackColor = System.Drawing.Color.FromArgb((int)(uint)this.size.colorRef); this.chkHoriLayout.Checked = this.size.HorizontalLayout; this.chkVertLayout.Checked = this.size.VerticalLayout; // indexSubTableArray this.listView1.Items.Clear(); fixed(byte *pImg = &this.file.image[0]) { indexSubTableArray *subtableAB = (indexSubTableArray *)(pImg + (uint)entry.offset + (uint)size.indexSubTableArrayOffset); indexSubTableArray *subtableAM = subtableAB + (uint)size.numberOfIndexSubTables; indexSubTableArray *subtableA = subtableAB; indexSubHeader * subheader; while (subtableA < subtableAM) { subheader = (indexSubHeader *)((byte *)subtableAB + (uint)subtableA->additionalOffsetToIndexSubTable); string[] items = new string[] { string.Format("{0:X4} - {1:X4}", (ushort)subtableA->firstGlyphIndex, (ushort)subtableA->lastGlyphIndex) , subheader->IndexFormatString , subheader->ImageFormatString , subheader->NumberOfGlyph(*subtableA).ToString() }; this.listView1.Items.Add(new System.Windows.Forms.ListViewItem(items)); subtableA++; } } }