10*10的gif无动画背景透明图片,怎样把他画布大小改变成20*20啊,背景需要透明,是改画布大小啊,不是图像的大小

解决方案 »

  1.   

    简单点,把你的gif动画放在table里,让table模拟它的画布。修改table的宽度和高度。
      

  2.   

    在Drawing 试试,在google里找找
      

  3.   

    天!god!如来! 
    画布大小,什么需求?
    程序员该死吗?
      

  4.   

    photoshop  或 firework 都ok
      

  5.   

    用panel模拟画布,把前景画在上面
      

  6.   

    创建一个一般处理文件imageFile.ashx,里面内容为:
                Bitmap bitmap = new Bitmap(20, 20, Graphics.FromImage(new Bitmap(imagefilename)));
                 context.Response.ContentType = "Image/GIF";
                        context.Response.Clear();
                        context.Response.BufferOutput = true;
                        bitmap.Save(context.Response.OutputStream, ImageFormat.Gif);
    然后把image的src指向该文件
      

  7.   

    新建一个透明背景的20×20的bitmap,然后把原来的图画上去就可以了
      

  8.   


                Bitmap source = new Bitmap("file");
                Bitmap bmp = new Bitmap(20,20);
                Graphics g = Graphics.FromImage(bmp);
                g.FillRectangle(Brushes.Transparent, 0,0,20,20);
                g.DrawImage(source,5,5);
      

  9.   

    很难吗?
    创建一个20*20的Bitmap,然后把gif DrawImage到Bitmap上,然后Bitmap.Save,格式参数选Gif就可以了。
      

  10.   

    存在两种情况:
    1.用PHOTOSHOP直接修改。
    2.用程序代理完成:   Bitmap source = new Bitmap("file");
                Bitmap bmp = new Bitmap(20,20);
                Graphics g = Graphics.FromImage(bmp);
                g.FillRectangle(Brushes.Transparent, 0,0,20,20);
                g.DrawImage(source,5,5);
      

  11.   

    Bitmap bit = new Bitmap(32, 32,PixelFormat.Format32bppArgb);
                Graphics g = Graphics.FromImage(bit);
                //Image img = Image.FromFile(@"D:\tool\2005\demo\battery1.gif");
                g.Clear(Color.Transparent);
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.InterpolationMode = InterpolationMode.High;
                g.DrawImage(bit,0, 0);
                bit.Save(@"D:\tool\2005\demo\a.gif",System.Drawing.Imaging.ImageFormat.Gif);
                g.Dispose();
                //img.Dispose();
                bit.Dispose();按照楼上的说法做不行啊  背景还是黑色的
      

  12.   

    楼上的都没理解清楚如果新建一画布,把GIF画上去,那GIF可能有多帧,怎么画?如果按上面说的做法,应该一帧一帧的画,再生成GIF格式图片,还要去除背景,这个工作量就很大了这个问题是有点难度,今天没时间了,等我想想先
      

  13.   

    不是很明白你的意思,画布??首先加载gif
    System.Drawing.Bitmap gif = new Bitmap("x:\x.gif");把PictureBox当作画布,图像居中
    PictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;背景透明什么意思?
    PictureBox.BackColor = System.Drawing.Color.Transparent;这个?大小
    PictureBox.Height = gif.Height + 10;
    PictureBox.Width = gif.Width + 10;PictureBox.Image = gif;要实现真正的画布就复杂了
      

  14.   

    思路:
        Graphics g=Graphics.FromImage(new Bitmap(20,20));
      

  15.   

    oh.sorry,没明白楼主的意思 就发言了。呵呵
      

  16.   

    Bitmap newImage = new Bitmap(20, 20);
                Image image = Image.FromFile(@"C:\Users\Mike\Desktop\bg.gif");
                Graphics g = Graphics.FromImage(newImage);            g.DrawImage(image, new Rectangle(5, 5, 10, 10),
                    new Rectangle(0, 0, 10, 10),
                    GraphicsUnit.Pixel);
             
                
                newImage.Save(@"C:\Users\Mike\Desktop\bg1.gif");
                newImage.Dispose();
                image.Dispose();
                g.Dispose();
      

  17.   

    哎  无知是可怕的。
    gif是有很多帧,但是作为Image对象打开只能看到第一帧新建的Bitmap当然是不透明的,要手动设置才行。
    Bitmap bmp = new Bitmap(20, 20);
    for (int i = 0; i < bmp.Width; ++i)
    {
        for (int j = 0; j < bmp.Height; ++j)
        {
             bmp.SetPixel(i, j, Color.Transparent);
        }
    }
      

  18.   

    在我上次发给你的加上这个函数        public static void MakeLargeImage(
                Size largeSize,
                string imagePath,
                string outputImagePath,
                Color transparentColor)
            {
                Image img = Image.FromFile(imagePath);
                Bitmap bmp = new Bitmap(largeSize.Width, largeSize.Height);
                Graphics graphics = Graphics.FromImage(bmp);
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;            RectangleF destRect = new RectangleF(
                    (largeSize.Width - img.Width) / 2.0f,
                    (largeSize.Height - img.Height) / 2.0f,
                    img.Width,
                    img.Height);
                RectangleF srcRect = new RectangleF(
                    -1.0f, 
                    -1.0f,
                    img.Width + 2, 
                    img.Height + 2);            using (SolidBrush brush = new SolidBrush(transparentColor))
                {
                    graphics.FillRectangle(
                        brush,
                        0,
                        0,
                        largeSize.Width,
                        largeSize.Height);
                }            graphics.DrawImage(
                    img,
                    destRect,
                    srcRect,
                    GraphicsUnit.Pixel);            graphics.Flush();
                graphics.Dispose();            MakeImage(bmp, outputImagePath);
            }
      

  19.   


    public static void MakeLargeImage(
                Size largeSize,
                string imagePath,
                string outputImagePath,
                Color transparentColor)
            {
                Image img = Image.FromFile(imagePath);
                Bitmap bmp = new Bitmap(largeSize.Width, largeSize.Height);
                Graphics graphics = Graphics.FromImage(bmp);
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;            Rectangle destRect = new Rectangle(
                    (largeSize.Width - img.Width) / 2,
                    (largeSize.Height - img.Height) / 2,
                    img.Width,
                    img.Height);
                Rectangle srcRect = new Rectangle(
                    0, 
                    0,
                    img.Width, 
                    img.Height);            using (SolidBrush brush = new SolidBrush(transparentColor))
                {
                    graphics.FillRectangle(
                        brush,
                        -1,
                        -1,
                        largeSize.Width + 2,
                        largeSize.Height + 2);
                }            graphics.DrawImage(
                    img,
                    destRect,
                    srcRect,
                    GraphicsUnit.Pixel);            graphics.Flush();
                graphics.Dispose();            MakeImage(bmp, outputImagePath);
            }
      

  20.   

    看看这个把保存透明的GIF   BITMAP设置ALPHA的值为0 然后保存成GIF就为透明了
    http://blog.csdn.net/zgke/archive/2008/11/28/3401077.aspx
      

  21.   

    如果是改改图片的话用Flash
    如果写代码的话
    Color   c   =   Color.FromArgb(0x66666666);   
      Bitmap   b   =   new   Bitmap(100,   100,   PixelFormat.Format32bppArgb);   
      for(int   x   =   0;   x   <   100;   x++)   
      {   
      for(int   y   =   0;   y   <   100;   y++)   
      {   
      b.SetPixel(x,   y,   c);   
      }   
      }   
      this.pictureBox1.Image   =   b;