大哥们:
    小弟在往位图里绘制文字时,发现画上去的文字边缘有灰色成份,这样我如果生成一张黑白图像的话,文字就不饱满了。请问该如何解决这个问题。

解决方案 »

  1.   

    //-下面函数 往图片上加字 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;
    }
      

  2.   

    TO csShooter(Sharp Shooter)大哥:
    取消字体边沿自动处理,这个什么地方可以设定吗?