怎样在一张图片上,获取坐标,动态加载标识(例如一个圈上写上数字),不希望用插件来实现请各位大侠帮忙。。在线等。。分不够再加。

解决方案 »

  1.   

    System.Web.HttpFileCollection MyFileCollection=Request.Files;
    System.Web.HttpPostedFile  MyFile = MyFileCollection[0];
    MakeSmallImg(MyFile,filename);
    ---------------------------------------------------
    public void MakeSmallImg(System.Web.HttpPostedFile postFile,string saveImg )
    {
    ///文字水印
    //从文件取得图片对象
    System.Drawing.Image image = System.Drawing.Image.FromStream(postFile.InputStream,true);
    //取得图片大小
    System.Drawing.Size size = new Size(image.Height,image.Width);
    System.Drawing.Image bitmap = new System.Drawing.Bitmap(size.Width,size.Height);
    //获得原图片的长与宽size.Width,size.Height
    System.Drawing.Graphics G=System.Drawing.Graphics.FromImage(bitmap);
    System.Drawing.Font fonts=new Font("楷体_GB2312",22);
    System.Drawing.Brush b=new SolidBrush(Color.Red);
    float x=5;
    float y=5;
    G.DrawString("文字水印",fonts,b,x,y);
    G.Dispose();
    //保存高清晰度的缩略图
    bitmap.Save(strGoodFile, System.Drawing.Imaging.ImageFormat.Jpeg);
    image.Dispose();
    bitmap.Dispose();
    }
      

  2.   

    Private static Bitmap getImage(string s){
      Bitmat b= new bitmap(1,1);
      int width,height;
      
    //Creat a font object
      font afont= new Font("Times New Roman",24,System.Dwawing.GraphicsUnit.Point);
      
    //create a graphics class to measure the text width
      Graphics Graphics =Graphics.FromImage(b)//Resize the bitmap
      width=(int)graphics.Measurestring(s,aFont).width;
      height =(int)graphics.MeasureString(s,aFont).Height;
      b=New Bitmap(b,new Size(width,height));
      
      graphics= Graphics.FromImage(b);
      graphics.Clear(Color.Black);
      graphics.TextRenderingHint = TextrenderingHint.AntiAlias;
      graphics.DrawString(s,Afont, hew SolidBrush(Color.Yellow),0,0);
      graphics.Flush();
      returnt(b);
    }
    我这段代码是输入一串字符串转换成图形的.希望对你有帮助!