bitmap - JPEG decompression from MemoryStream c# -
in program, compress bmp jpeg this:
private void convertbmptostreamjpg30(bitmap b, stream s) { s.flush(); encoderparameters encoderparameters = new encoderparameters(1); encoderparameters.param[0] = new encoderparameter(system.drawing.imaging.encoder.quality, 30l); b.save(s, getencoder(imageformat.jpeg), encoderparameters); }
then function receiving jpeg in memorystream, transform bitmap doing
bitmap b = new bitmap(stream);
when display image, there lot of lines :
what doing wrong, people?
edit 1 here small visual studio solution showing problem: http://www.fast-files.com/getfile.aspx?file=79311
it beginning of screen sharing software. does: takes screenshots, compare them, compress difference , send part of program decompress , recompose image received. opens window displaying "sent" on left , recomposed image on right.
three things come mind:
- try setting better quality 30 , see if helps;
- check ram (and possibly video ram, though doubt gdi+ might use vga compression) hardware problems;
- i've had similar weird problem loaded jpeg file, modified bit, , saved again. produced exception. solution make new bitmap based on old 1 , save copy. try that.
Comments
Post a Comment