Exemplo n.º 1
0
 protected override void saveImage(ui.Image image, java.io.OutputStream response, string format, float quality)
 {
     CanvasBitmapFileFormat fileFormat = CanvasBitmapFileFormat.Png;
     if (format.Equals(FORMAT_JPEG))
     {
         fileFormat = CanvasBitmapFileFormat.Jpeg;
     }
     CodenameOneImage img = (CodenameOneImage)image.getImage();
     CanvasBitmap cb = img.image;
     InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream();
     cb.SaveAsync(ms, fileFormat, quality).AsTask().ConfigureAwait(false).GetAwaiter().GetResult(); ;
     ms.Seek(0);
     byte[] buf = new byte[ms.Size];
     DataReader dr = new DataReader(ms);
     dr.LoadAsync((uint)ms.Size).AsTask().ConfigureAwait(false).GetAwaiter().GetResult(); ;
     dr.ReadBytes(buf);
     response.write(buf);
 }
Exemplo n.º 2
0
 public override void saveImage(ui.Image image, java.io.OutputStream response, java.lang.String format, float quality)
 {
     CanvasBitmapFileFormat fileFormat = CanvasBitmapFileFormat.Png;
     if (format.equals(_fFORMAT_1JPEG))
     {
         fileFormat = CanvasBitmapFileFormat.Jpeg;
     }
     CodenameOneImage img = (CodenameOneImage)image.getImage();
     CanvasBitmap cb = img.image;
     InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream();
     cb.SaveAsync(ms, fileFormat, quality).AsTask().ConfigureAwait(false).GetAwaiter().GetResult(); ;
     ms.Seek(0);
     byte[] buf = new byte[ms.Size];
     DataReader dr = new DataReader(ms);
     dr.LoadAsync((uint)ms.Size).AsTask().ConfigureAwait(false).GetAwaiter().GetResult(); ;
     dr.ReadBytes(buf);
     response.write(new _nArrayAdapter<sbyte>(SilverlightImplementation.toSByteArray(buf)));
 }
 public override bool isOpaque(ui.Image n1, java.lang.Object n2) {
     return ((CodenameOneImage)n1.getImage()).opaque;
 }