首页 > 编程知识 正文

字母,英语音标

时间:2023-05-04 11:06:04 阅读:57438 作者:3790

转换为24位RGB灰度格式:有关此方法的讨论过程和示例,请参阅粘贴。 C#如何将【记录了图像信息的二进制文件】转换为可以正常打开的图像文件?

privatevoidbutton2_ click (对象发送器,EventArgs e ) vardata=file.readallbytes(@ '输入文件路径. raw ' ); int w=1240; int h=1210; bitmapbitm=newbitmap(w,h,PixelFormat.Format24bppRgb ); //建立了位图框架,24位格式(可以在此更改位深度) int i=0; for(vary=0; y h; y ) for(varx=0; x w; x({varn=data[I]; BITM.setpixel(x,y,Color.FromArgb(n ),n,n ); //以像素为单位分配值(仅当有四个参数时才匹配ARGB32位格式) } } pictureBox1.Image=bitm; pictureBox1.Refresh (; //更新显示内容bitm.save(@ '输出文件路径. png )、system.drawing.imageformat.png ); }转换为8位调色板(Palette )灰度格式)此格式占用的空间很小(privatevoidbutton3_ click (对象发送器,事件e ) var image data=int imageHeight=1210; //将数组转换为intptrintptrpData=marshal.all och全局(imageWidth * imageHeight )的marshal.copy(imagedata,0,pdata,ime //创建灰度位图bitmap BMP=new bitmap (图像宽度,图像高度,图像宽度,PixelFormat.Format8bppIndexed,pData ) //用于修改位图的调色板color palette palette=BMP.palette; for(intI=0; i 256; I ) { palette.entries [ I ]=color.from argb (I,I,I ); } bmp.Palette=palette; picturebox1. image=查看和保存BMP picturebox1. refresh (; bmp.save(@ '输出文件路径. BMP )、ImageFormat.Bmp ); }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。