您的位置:程序门 -> .net技术 -> c#



关于png和jpeg图像格式的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于png和jpeg图像格式的问题[已结贴,结贴人:retnuh]
发表于:2007-03-07 11:14:43 楼主
public   bitmap   _image;
  _image   =   seismicmap._sectionimage   ;
    _image.save(response.outputstream,   imageformat.png);

以上,_image内存有一副图片,以上述代码将此图像以指定的格式保存到流中,问题是为什么png格式会报错,而jpeg格式没问题,但是我要做无损压缩,所以想用png格式,另外,jpeg格式有1-10种(我记不太清楚了)不同的压缩格式,这个该怎么调整呢,在c#中
发表于:2007-03-09 10:21:201楼 得分:5
up
发表于:2007-03-10 10:00:452楼 得分:30
http://www.microsoft.com/china/msdn/library/archives/library/dnaspp/html/colorquant.asp

http://blog.csdn.net/syqqman/archive/2006/05/15/729177.aspx
发表于:2007-03-12 11:24:353楼 得分:0
我再顶,我按照楼上的方法做了,可得出来的图像效果感觉差异不大,另外,为什么
  _image.save(response.outputstream,   imageformat.png);
这句话会报错呢,说不支持这种格式,可是
  _image.save( "c://new.png ",   imageformat.png);
这种输出到文件的方法是可以正常运行的啊,为什么输出到屏幕就不行了呢?
发表于:2007-03-12 11:24:584楼 得分:0
我再顶顶,嘿嘿,不会删我贴吧
发表于:2007-03-12 11:29:205楼 得分:5
jpeg也可以无损,指定最高质量就可以了
发表于:2007-03-12 11:42:176楼 得分:5
维也纳升的好快
发表于:2007-03-12 12:09:477楼 得分:5
该回复于2007-10-26 14:37:40被管理员删除
发表于:2007-03-12 14:14:088楼 得分:0
感谢维也纳,再顶一下~关于_image.save(response.outputstream,   imageformat.png);报错的问题不知道有人能回答下不?
发表于:2007-03-13 10:39:479楼 得分:0
没人理了?再顶顶~
发表于:2007-03-13 10:49:4810楼 得分:15
沒有這樣用過   ,都是向文件或內存流輸出。樓主指定   image/png   了嗎?

而且你是在網頁上輸出指定最高質量的jpeg已經足夠了。肉眼是看不出差別的。
发表于:2007-03-13 15:03:0711楼 得分:10
任何时候都应该先写入memorystream对象,在用memorystream写入response.outputstream
发表于:2007-03-13 17:12:0612楼 得分:0
回楼上,我开始是这样写的,能运行,但是跟踪进去发现response.outputstream有几个地方提示异常~
  response.contenttype   =   "image/png ";
  memorystream   memstr=new   memorystream();
  _image.save(memstr,imageformat.png);
  memstr.writeto(response.outputstream);

发表于:2007-03-14 09:27:2313楼 得分:5

那就不知道什么异常了,检查一下程序吧,可能是错误在图形的绘制过程中..
发表于:2007-03-14 09:38:0114楼 得分:5
jf
发表于:2007-03-14 09:57:4515楼 得分:0
好了,中午结贴,不过纯粹jf俩字母的仁兄偶真不想给你分,看在帮顶的份上就给你5分吧~
发表于:2007-03-14 10:01:0416楼 得分:5
up
发表于:2007-03-14 10:13:0817楼 得分:10
我刚刚试过了,先写入内存流,再输出的方法是可行的。如果这样都不可行,那真的没道理可讲了。

另外:
png 's   are   a   special   case.   their   encoder   requires   a   bi-directional   stream.   the   solution   is   to   stream   to   a   memory   stream   first   and   write   the   contents   of   that   memory   stream   to   outputstream   afterwards.  

when   you   get   to   caching   (which   i 've   just   implemented)   you 'll   be   writing   to   a   memory   stream   anyway   just   to   cache   the   output,   so   this   isn 't   a   big   deal.  

as   far   as   the   gif   end   of   things   goes,   the   default   palletization   of   the   built   in   gif   encoder   leaves   something   to   be   desired.   i 've   built   in   support   for   an   octree   quantizer   to   deal   with   this.  



快速检索

最新资讯
热门点击