public byte[] GetCharacterIndex(IZiCharacter character, uint dataoffset, int length) { var bytes = new byte[10]; var codepointbytes = BitConverter.GetBytes(character.CodePoint); bytes[0] = codepointbytes[0]; bytes[1] = codepointbytes[1]; bytes[2] = character.Width; bytes[3] = character.KerningLeft; bytes[4] = character.KerningRight; var offsetbytes = BitConverter.GetBytes(dataoffset); bytes[5] = offsetbytes[0]; bytes[6] = offsetbytes[1]; bytes[7] = offsetbytes[2]; var sizebytes = BitConverter.GetBytes((ushort)length); bytes[8] = sizebytes[0]; bytes[9] = sizebytes[1]; return(bytes); }
public static void CopyToClipboard(IZiCharacter character) { var bmp = character.ToBitmap(); if (bmp == null) { return; } // Remove transparency var clip = new Bitmap(bmp.Width, bmp.Height); using (var graphics = Graphics.FromImage(clip)) { graphics.FillRectangle(Brushes.White, 0, 0, clip.Width, clip.Height); graphics.DrawImage(bmp, 0, 0); } Clipboard.SetImage(clip); clip.Dispose(); }
public static bool PasteFromClipboard(IZiCharacter character) { try { if (Clipboard.ContainsData("PNG")) { object png = Clipboard.GetData("PNG"); if (png is MemoryStream) { MemoryStream pngstream = png as MemoryStream; var clip = Image.FromStream(pngstream); var newbmp = Convert(new Bitmap(clip)); character.SetBitmap(newbmp); clip.Dispose(); return(true); } } } catch { } if (Clipboard.ContainsImage()) { var clip = Clipboard.GetImage(); if (clip.Height > character.Parent.CharacterHeight) { var newbmp = Convert(new Bitmap(clip)); character.SetBitmap(newbmp); clip.Dispose(); return(true); } else { var newbmp = Convert(new Bitmap(clip)); character.SetBitmap(newbmp); clip.Dispose(); return(true); } } return(false); }
public static void CopyToClipboard(IZiCharacter character) { var bmp = character.ToBitmap(); if (bmp == null) { return; } // Remove transparency var clip = new Bitmap(bmp.Width, bmp.Height); Color color; using (var graphics = Graphics.FromImage(clip)) { graphics.FillRectangle(Brushes.White, 0, 0, clip.Width, clip.Height); //graphics.DrawImage(bmp, 0, 0); } // Remove ForegroundColor, replace with black for (int y = 0; y < bmp.Height; y++) { for (int x = 0; x < bmp.Width; x++) { color = Color.FromArgb(bmp.GetPixel(x, y).A, Color.Black); clip.SetPixel(x, y, color); } } var clip2 = new Bitmap(bmp.Width, bmp.Height); using (var graphics = Graphics.FromImage(clip2)) { graphics.FillRectangle(Brushes.White, 0, 0, clip.Width, clip.Height); graphics.DrawImage(clip, 0, 0); } Clipboard.SetImage(clip2); clip.Dispose(); clip2.Dispose(); }
public void AddCharacter(uint codepoint, IZiCharacter character) { Characters.Add(character); }
public void AddCharacter(uint codepoint, IZiCharacter character) { }