彩色图像转黑白图像 大哥们: 小弟在往位图里绘制文字时,发现画上去的文字边缘有灰色成份,这样我如果生成一张黑白图像的话,文字就不饱满了。请问该如何解决这个问题。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //-下面函数 往图片上加字 private string overlay(string imgSrc1,int imgLeft1,int imgTop1,string strFont1,string strSize1,string strColor1,string strText1,double cur_width,double cur_height) { //Response.Write("<script>alert('"+strColor1+"');</script>"); //int lenImage1=imgSrc1.Length-4; DateTime now1=DateTime.Now; string RD=now1.ToString("yyyyMMddHHmmss"); string imgPath=imgSrc1.Substring(imgSrc1.IndexOf("/upimages/")+10);; //imgPath=imgPath.Substring(imgPath.IndexOf('/')+1); //imgPath=imgPath.Substring(imgPath.IndexOf('/')+1); imgPath=imgPath.Substring(0,imgPath.LastIndexOf('/')+1); string imgName=imgSrc1.Substring(imgSrc1.LastIndexOf('/')+1); string subGet=imgSrc1.Substring(imgSrc1.LastIndexOf('.')); string sd=Session.SessionID.ToString(); string newImgSrc=""; newImgSrc=Server.MapPath("upimages\\diytemp\\")+sd+RD+RD+subGet; string tempPath=Server.MapPath("upimages/"+imgPath)+imgName; double imageWidth=0; double imageHigh=0; //取图片像素 System.Drawing.Image oldImage=System.Drawing.Image.FromFile(tempPath); //根据比例 缩小 imageWidth=cur_width; imageHigh =cur_height; // 生成缩微图 .JPG! System.Drawing.Image thumbnailImage =oldImage.GetThumbnailImage((int)imageWidth,(int)imageHigh,new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); Bitmap output=new Bitmap(thumbnailImage); //存储类型 output.Save(newImgSrc,System.Drawing.Imaging.ImageFormat.Jpeg); //释放资源 output.Dispose(); oldImage.Dispose(); thumbnailImage.Dispose(); //RenderImage(imgSrc1,strText1,newImgSrc); System.Drawing.Image oldImage1=System.Drawing.Image.FromFile(newImgSrc); Bitmap myBitmap1 = new Bitmap(oldImage1); Graphics g = Graphics.FromImage(myBitmap1); Font aFont=new Font(strFont1,(float)(int.Parse(strSize1)),System.Drawing.GraphicsUnit.Point); Brush aBrush=new SolidBrush(System.Drawing.ColorTranslator.FromHtml(strColor1)); g.DrawString(strText1,aFont,aBrush,imgLeft1,imgTop1,System.Drawing.StringFormat.GenericTypographic); //g.DrawString(strText1,aFont,System.Drawing.Brushes.Blue,rec); newImgSrc=Server.MapPath("upimages\\diytemp\\")+sd+RD+subGet; myBitmap1.Save(newImgSrc,System.Drawing.Imaging.ImageFormat.Jpeg); // 清除缓冲 //Response.Clear(); aFont.Dispose(); oldImage1.Dispose(); myBitmap1.Dispose(); g.Dispose(); txtlenImage+=1; txttimeImage=RD; string imgsrc="upimages/diytemp/"+sd+RD+subGet; return imgsrc; } TO csShooter(Sharp Shooter)大哥:取消字体边沿自动处理,这个什么地方可以设定吗? 可以将byte转换成byte[] TextBox 禁用后 怎么修改其背景色 DirectoryEntry操作AD的一点疑问,欢迎指教。。。 c#中关于ListBox框的小问题 sqlcommand如何update一个image字段? 在VS环境XML与treeview怎么解决啊!急! 请教一个在C#中使用HTTP的问题! 高手帮忙啊,郁闷了一个晚上,在线等…… 郁闷呀~~迷茫~~~ datagrid添加新行问题 很简单的问题但是该不明白,C和C#的main函数有什么区别? asp.net一个让我很郁闷的问题!!求教
{
//Response.Write("<script>alert('"+strColor1+"');</script>");
//int lenImage1=imgSrc1.Length-4;
DateTime now1=DateTime.Now;
string RD=now1.ToString("yyyyMMddHHmmss");
string imgPath=imgSrc1.Substring(imgSrc1.IndexOf("/upimages/")+10);;
//imgPath=imgPath.Substring(imgPath.IndexOf('/')+1);
//imgPath=imgPath.Substring(imgPath.IndexOf('/')+1);
imgPath=imgPath.Substring(0,imgPath.LastIndexOf('/')+1);
string imgName=imgSrc1.Substring(imgSrc1.LastIndexOf('/')+1);
string subGet=imgSrc1.Substring(imgSrc1.LastIndexOf('.'));
string sd=Session.SessionID.ToString();
string newImgSrc="";
newImgSrc=Server.MapPath("upimages\\diytemp\\")+sd+RD+RD+subGet;
string tempPath=Server.MapPath("upimages/"+imgPath)+imgName; double imageWidth=0;
double imageHigh=0; //取图片像素
System.Drawing.Image oldImage=System.Drawing.Image.FromFile(tempPath);
//根据比例 缩小
imageWidth=cur_width;
imageHigh =cur_height;
// 生成缩微图 .JPG!
System.Drawing.Image thumbnailImage =oldImage.GetThumbnailImage((int)imageWidth,(int)imageHigh,new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
Bitmap output=new Bitmap(thumbnailImage);
//存储类型
output.Save(newImgSrc,System.Drawing.Imaging.ImageFormat.Jpeg);
//释放资源
output.Dispose();
oldImage.Dispose();
thumbnailImage.Dispose();
//RenderImage(imgSrc1,strText1,newImgSrc);
System.Drawing.Image oldImage1=System.Drawing.Image.FromFile(newImgSrc);
Bitmap myBitmap1 = new Bitmap(oldImage1);
Graphics g = Graphics.FromImage(myBitmap1); Font aFont=new Font(strFont1,(float)(int.Parse(strSize1)),System.Drawing.GraphicsUnit.Point);
Brush aBrush=new SolidBrush(System.Drawing.ColorTranslator.FromHtml(strColor1));
g.DrawString(strText1,aFont,aBrush,imgLeft1,imgTop1,System.Drawing.StringFormat.GenericTypographic);
//g.DrawString(strText1,aFont,System.Drawing.Brushes.Blue,rec);
newImgSrc=Server.MapPath("upimages\\diytemp\\")+sd+RD+subGet;
myBitmap1.Save(newImgSrc,System.Drawing.Imaging.ImageFormat.Jpeg);
// 清除缓冲
//Response.Clear();
aFont.Dispose();
oldImage1.Dispose();
myBitmap1.Dispose();
g.Dispose(); txtlenImage+=1;
txttimeImage=RD; string imgsrc="upimages/diytemp/"+sd+RD+subGet;
return imgsrc;
}
取消字体边沿自动处理,这个什么地方可以设定吗?