Guest User

Untitled

a guest
Feb 12th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1.    public static class Function1
  2.     {
  3.         /*  public static void Run(string background, string overlay, CloudBlockBlob outputBlob, TraceWriter log)    */
  4.  
  5.         [FunctionName("ConvertMe")]
  6.         public async static Task RunASync([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
  7.             [Blob("Test", FileAccess.ReadWrite)]CloudBlockBlob Image1,
  8.             [Blob("Test", FileAccess.ReadWrite)]CloudBlockBlob Image2,
  9.             CloudBlockBlob outputBlob,ILogger log)
  10.         {
  11.  
  12.             log.LogInformation($"Function triggered with blob\n Background: {Image1.Name} \n Overlay: {Image2.Name}");
  13.            
  14.             ConvertMe Converter = new ConvertMe(System.Drawing.Color.Black);
  15.             Bitmap _Main = new Bitmap(Image1.StorageUri.PrimaryUri.AbsolutePath);
  16.             Bitmap Overlay = Converter.MakeTransparent(Image2.StorageUri.PrimaryUri.AbsolutePath);
  17.  
  18.            
  19.  
  20.             using (MemoryStream memory = new MemoryStream())
  21.             {
  22.                 Converter.ComebineBitmap(_Main, Overlay).Save(memory, ImageFormat.Jpeg);
  23.                 memory.Position = 0;
  24.                 outputBlob.Properties.ContentType = "image/jpeg";
  25.                  await  outputBlob.UploadFromStreamAsync(memory);
  26.             }
  27.  
  28.  
  29.         }
  30.    
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment