LayerGenerator.cs 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. using System.Windows.Media.Imaging;
  2. namespace PixiEditor.Models.Layers
  3. {
  4. public static class LayerGenerator
  5. {
  6. /// <summary>
  7. /// Generating useable layer with image and bitmap
  8. /// </summary>
  9. /// <param name="imageWidth">Width of layer.</param>
  10. /// <param name="imageHeight">Height of layer.</param>
  11. /// <returns></returns>
  12. public static Layer Generate(int imageWidth, int imageHeight)
  13. {
  14. return new Layer(GenerateBitmap(imageWidth, imageHeight));
  15. }
  16. /// <summary>
  17. /// Generates bitmap ready to work with
  18. /// </summary>
  19. /// <param name="bitmapWidth">Width of bitmap.</param>
  20. /// <param name="imageHeight">Height of bitmap.</param>
  21. /// <returns></returns>
  22. private static WriteableBitmap GenerateBitmap(int bitmapWidth, int imageHeight)
  23. {
  24. WriteableBitmap bitmap = BitmapFactory.New(bitmapWidth, imageHeight);
  25. bitmap.Clear(System.Windows.Media.Colors.Transparent);
  26. return bitmap;
  27. }
  28. }
  29. }