绘制bitmap图片保存,生成ico文件或者对象
2008-09-10 15:49
615 查看
自己绘制bitmap图片保存,生成ico文件或者对象
今天回答一个问题的时候的随笔
Bitmap bit = new Bitmap(100, 30);
Graphics g = Graphics.FromImage(bit);
SolidBrush sb = new SolidBrush(Color.Blue);
Rectangle rg = new Rectangle(new Point(0, 0), bit.Size);
g.FillRectangle(sb, rg);
g.DrawString("测试测试呵呵", this.Font, new SolidBrush(Color.White), new PointF(0, 0));
bit.Save("d://123.bmp");//保存下来这个可以看生成的图片
msdn上面有详解,先将你需要生成的图片与文字合成一个image对象,然后生成icon对象,最后用Graphics 操作或者直接用icon类进行操作
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse(这是 Paint 事件处理程序的参数)。代码执行下列操作:
创建一个 Bitmap。
将该对象绘制到屏幕。
获取 Bitmap 的图标句柄。
将窗体的 Form.Icon 属性设置为从该句柄创建的图标。
调用 Win32 API 函数 DestroyIcon 以释放资源。
C# code
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet=CharSet.Auto)]
extern static bool DestroyIcon(IntPtr handle);
private void GetHicon_Example(PaintEventArgs e)
{
// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap(@"c:/FakePhoto.jpg");
// Draw myBitmap to the screen.
e.Graphics.DrawImage(myBitmap, 0, 0);
// Get an Hicon for myBitmap.
IntPtr Hicon = myBitmap.GetHicon();
// Create a new icon from the handle.
Icon newIcon = Icon.FromHandle(Hicon);
// Set the form Icon attribute to the new icon.
this.Icon = newIcon;
// Destroy the Icon, since the form creates
// its own copy of the icon.
DestroyIcon(newIcon.Handle);
}
今天回答一个问题的时候的随笔
Bitmap bit = new Bitmap(100, 30);
Graphics g = Graphics.FromImage(bit);
SolidBrush sb = new SolidBrush(Color.Blue);
Rectangle rg = new Rectangle(new Point(0, 0), bit.Size);
g.FillRectangle(sb, rg);
g.DrawString("测试测试呵呵", this.Font, new SolidBrush(Color.White), new PointF(0, 0));
bit.Save("d://123.bmp");//保存下来这个可以看生成的图片
msdn上面有详解,先将你需要生成的图片与文字合成一个image对象,然后生成icon对象,最后用Graphics 操作或者直接用icon类进行操作
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse(这是 Paint 事件处理程序的参数)。代码执行下列操作:
创建一个 Bitmap。
将该对象绘制到屏幕。
获取 Bitmap 的图标句柄。
将窗体的 Form.Icon 属性设置为从该句柄创建的图标。
调用 Win32 API 函数 DestroyIcon 以释放资源。
C# code
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet=CharSet.Auto)]
extern static bool DestroyIcon(IntPtr handle);
private void GetHicon_Example(PaintEventArgs e)
{
// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap(@"c:/FakePhoto.jpg");
// Draw myBitmap to the screen.
e.Graphics.DrawImage(myBitmap, 0, 0);
// Get an Hicon for myBitmap.
IntPtr Hicon = myBitmap.GetHicon();
// Create a new icon from the handle.
Icon newIcon = Icon.FromHandle(Hicon);
// Set the form Icon attribute to the new icon.
this.Icon = newIcon;
// Destroy the Icon, since the form creates
// its own copy of the icon.
DestroyIcon(newIcon.Handle);
}
相关文章推荐
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byt
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- 将bitmap对象保存为一个图片文件
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- Android图像处理之Bitmap 生成图片 解析 保存文件 获取 问题
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- VFP将图片或其他文件保存到SQL Server的Text类型字段或者Access的备注字段中,并可以还原或显示
- 生成二维码并将Bitmap保存成图片
- 将UIImage对象保存到JPG或者PNG文件中
- 将html文件中的图片导出到某一文件夹或者生成xml文件
- 上传图片到服务器,服务器保存并且接收到了,但是必须刷新文件夹或者重新部署文件才能在客户端显示图片
- 图片文件与Bitmap对象的互相转化
- Android 使用Bitmap将自身保存为文件,BitmapFactory从File中解析图片并防止OOM
- sql server数据库保存图片或者其他小文件
- 保存图片控件上的图片到本地 出现错误:无法将类型为“System.Windows.Media.Imaging.BitmapFrameDecode”的对象强制转换为类型“System.Windows.Media.Imaging.BitmapImage”。
- Android—将Bitmap图片保存到SD卡目录下或者指定目录
- 通过 Bitmap Font Generator 生成 fnt 与 png 文件供 cocos2d-x 中 LabelBMFont 使用达到以图片表现数字
- android 文字或者图片生成.pdf文件