public Task <object> Create(byte[] imageData, int imageWidth, int imageHeight, int pixelByteCount) { return(Task.Run(async() => { byte[] bmpData = await BitmapCreator.Create((short)imageWidth, (short)imageHeight, imageData, false); return (object)BitmapFactory.DecodeByteArray(bmpData, 0, bmpData.Length); })); }
public void SaveImageTo(string exportPath) { var finalPath = exportPath + "/" + Texture.FileName + Texture.Extension; var bitmapEncoder = new BitmapCreator <PngBitmapEncoder>(); bitmapEncoder.AddBitmapFrame(Texture.Color); FileManager.SaveTextureFromEncoder(bitmapEncoder.Encoder, finalPath); }
/// <summary> /// Main program. /// </summary> /// <param name="args">Command line arguments.</param> static void Main(string[] args) { Helper = new ConsolePrinter(); Helper.Name = "Font2Bmp"; Helper.Description = "Converts a Windows font to a BMP file."; Helper.Version = "V1.2"; Helper.AddArgument(new Argument("FONT", "string", "Name of the Windows font to convert", false)); Helper.AddArgument(new Argument("SIZE", "int", "Size of the font in pixels", false)); Argument arg = new Argument("STYLE", "int", "Style of the font. Options are:", true); arg.AddOption("regular", "Standard font"); arg.AddOption("bold", "Bold font"); arg.AddOption("italic", "Italic font"); Helper.AddArgument(arg); Helper.AddArgument(new Argument("FILE", "int", "Output path and filename", false)); Helper.AddArgument(new Argument("BACKR", "int", "Red component of the background colour", true)); Helper.AddArgument(new Argument("BACKG", "int", "Green component of the background colour", true)); Helper.AddArgument(new Argument("BACKB", "int", "Blue component of the background colour", true)); Helper.AddArgument(new Argument("TEXTR", "int", "Red component of the text colour", true)); Helper.AddArgument(new Argument("TEXTG", "int", "Green component of the text colour", true)); Helper.AddArgument(new Argument("TEXTB", "int", "Blue component of the text colour", true)); Helper.AddArgument(new Argument("LIST", "int", "Lists all available Windows font names", true)); Helper.AddParagraph("If the background colour is not specified it defaults to white."); Helper.AddParagraph("If the text colour is not specified it defaults to black."); Helper.AddParagraph("If the style is not specified it defaults to regular."); // Output title Console.WriteLine(Helper.Title); // Fetch arguments ParseArgs(args); // Get the font to convert Font font = GetFont(mFontName, mFontSize, mFontStyle); // Convert the font to a bitmap Console.WriteLine("Converting font to bitmap..."); Bitmap bmp = BitmapCreator.CreateFontBitmap(font, mBackgroundR, mBackgroundG, mBackgroundB, mTextR, mTextG, mTextB); Console.WriteLine("Font converted."); Console.WriteLine(""); // Save the bitmap Console.WriteLine(String.Format("Saving bitmap to {0}...", mFileName)); bmp.Save(mFileName, System.Drawing.Imaging.ImageFormat.Bmp); Console.WriteLine("All done!"); }
public async void Create(double imageSize, double range, int step, double CentrumX = 0, double CentrumY = 0) { _eventAggregator.GetEvent <CreateCounterLineInfoEvent>().Publish(true); // Counterine is Creatng BitmapSize = imageSize; var pixelsCaclulator = new PixelsCaclulator(imageSize, imageSize, range, step, CentrumX, CentrumY); PointItems.Clear(); LinesConnectingPoints.Clear(); var centralCoordinate = pixelsCaclulator.CalculatePixel(CentrumX, CentrumY); CentralPoint = new PointItem(centralCoordinate, new Point(CentrumX, CentrumY), _calculatedPointSize); var pixels = await GetPixelsTask(pixelsCaclulator); Bitmap = BitmapCreator.CreateBitmap(pixels); _eventAggregator.GetEvent <CreateCounterLineInfoEvent>().Publish(false); // Counterine is not Creatng CalculatePointItemBasemOnCalculatedPoints(CalculatedPoints, pixelsCaclulator); }
/// <summary> /// Perform the conversion. /// </summary> static void ConvertFont() { // Use background colour that is opposite of text colour int backgroundR = mTextR ^ 255; int backgroundG = mTextG ^ 255; int backgroundB = mTextB ^ 255; // Get the font Font font = GetFont(mFontName, mFontSize, mFontStyle); // Convert the font to a bitmap Bitmap bmp = BitmapCreator.CreateFontBitmap(font, backgroundR, backgroundG, backgroundB, mTextR, mTextG, mTextB); // Convert bitmap to Woopsi font WoopsiFont woopsiFont = Converter.Convert(mFontName, mFontName, mFontType, bmp, bmp.Width / CHARS_PER_ROW, bmp.Height / ROWS_PER_FONT, backgroundR, backgroundG, backgroundB); // Output files WriteFile(mOutputPath + "\\" + woopsiFont.HeaderFileName, woopsiFont.HeaderContent); WriteFile(mOutputPath + "\\" + woopsiFont.BodyFileName, woopsiFont.BodyContent); }
/// <summary> /// Main program. /// </summary> /// <param name="args">Command line arguments.</param> static void Main(string[] args) { Helper = new ConsolePrinter(); Helper.Name = "Font2Font"; Helper.Description = "Converts a Windows font to a Woopsi font."; Helper.Version = "V1.2"; Helper.AddArgument(new Argument("FONT", "string", "Name of the Windows font to convert", false)); Helper.AddArgument(new Argument("SIZE", "int", "Size of the font in pixels", false)); Argument arg = new Argument("STYLE", "int", "Style of the font. Options are:", true); arg.AddOption("regular", "Standard font"); arg.AddOption("bold", "Bold font"); arg.AddOption("italic", "Italic font"); Helper.AddArgument(arg); arg = new Argument("FONTTYPE", "string", "Type of font to produce. Options are:", true); arg.AddOption("packedfont1", "Monochrome packed proportional font"); arg.AddOption("packedfont16", "16-bit packed proportional font"); Helper.AddArgument(arg); Helper.AddArgument(new Argument("PATH", "string", "Output path", false)); Helper.AddArgument(new Argument("R", "int", "Red component of the text colour", true)); Helper.AddArgument(new Argument("G", "int", "Green component of the text colour", true)); Helper.AddArgument(new Argument("B", "int", "Blue component of the text colour", true)); Helper.AddArgument(new Argument("LIST", "int", "Lists all available Windows font names", true)); Helper.AddParagraph("If the text colour is not specified it defaults to black."); Helper.AddParagraph("If the style is not specified it defaults to regular."); Helper.AddParagraph("If the path is not specified it defaults to the current path."); Helper.AddParagraph("If the font type is not specified it defaults to packedfont1."); Console.WriteLine(Helper.Title); Console.WriteLine(Helper.HelpText); // Fetch arguments ParseArgs(args); // Use background colour that is opposite of text colour int backgroundR = (mTextR ^ 255) & 255; int backgroundG = (mTextG ^ 255) & 255; int backgroundB = (mTextB ^ 255) & 255; // Get the font Font font = GetFont(mFontName, mFontSize, mFontStyle); // Convert the font to a bitmap Bitmap bmp = BitmapCreator.CreateFontBitmap(font, backgroundR, backgroundG, backgroundB, mTextR, mTextG, mTextB); // Convert bitmap to Woopsi font WoopsiFont woopsiFont = Converter.Convert(mFontName, mFontName, mFontType, bmp, bmp.Width / CHARS_PER_ROW, bmp.Height / ROWS_PER_FONT, backgroundR, backgroundG, backgroundB); // Output files WriteFile(mOutputPath + "\\" + woopsiFont.HeaderFileName, woopsiFont.HeaderContent); WriteFile(mOutputPath + "\\" + woopsiFont.BodyFileName, woopsiFont.BodyContent); Console.WriteLine("All done!"); }