c# - Converting FileStream to WriteableBitmap to JPEG to Byte Array for SSRS -
i'm trying save image sql server ssrs can read it. need convert writeablebitmap (and possibly jpeg?) can make changes image size before saving. however, when try pull converted image out of sql server, not render in ssrs @ all. doing wrong?
byte[] m_bytes = readtoend(filestream); //this works fine writeablebitmap bmp1 = new writeablebitmap(166, 166); bmp1.frombytearray(m_bytes); //this works fine extendedimage image = bmp1.toimage(); memorystream stream = new memorystream(); imagetools.io.encoders.addencoder<jpegencoder>(); jpegencoder encoder = new jpegencoder(); encoder.encode(image, stream); bitmapimage img = new bitmapimage(); img.setsource(stream); writeablebitmap bmp2 = new writeablebitmap(img); byte[] buffer1 = bmp2.tobytearray(); currentorder.companyimage = buffer1; //this save byte array not render in ssrs. if set buffer1 bmp1.tobytearray() works fine still unable resize using resize method in writeableex without not rendering in ssrs.
this try @ same thing , won't render either:
and simpler , won't work either:
byte[] m_bytes = readtoend(filestream); writeablebitmap bmp1 = new writeablebitmap(166, 166); bmp1.frombytearray(m_bytes); writeablebitmap resizedimage = bmp1.resize(25, 25, writeablebitmapextensions.interpolation.bilinear); byte[] buffer1 = resizedimage.tobytearray(); currentorder.companyimage = buffer1;
what want resize 166x166 (or 25x25), export byte[] , reload picture byte array ?
can try bitmapimage
?
bitmapimage image = new bitmapimage(); image.setsource(filestream); writeablebitmap bitmap = new writeablebitmap(image); writeablebitmap resizedbitmap = bitmap.resize(25, 25, writeablebitmapextensions.interpolation.bilinear); currentorder.companyimage = resizedbitmap.tobytearray();
Comments
Post a Comment