如何用C#建立一个4位或8位的图像(Bitmap)? 现在还不能。CSDN开发高手第七期上,有一篇文章《变色记》可以解决你说的问题。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Image image = null; Graphics g = null; StringFormat textFormat = null; Font textFont = null; Brush textBrush = null; Brush backBrush = null; try { // 初始参数 InitializeParameters(request); // 创建位图 image = new Bitmap(_width, _height, PixelFormat.Format32bppArgb); g = Graphics.FromImage(image); // 创建画笔 backBrush = new SolidBrush(_backColor); g.FillRectangle(backBrush, 0, 0, _width, _height); if (_text.Length != 0) { // 创建位图内容 textFormat = new StringFormat(StringFormatFlags.NoWrap); textFormat.Alignment = _horizontalAlign; textFormat.LineAlignment = _verticalAlign; FontStyle style = FontStyle.Regular; if (_bold) { style |= FontStyle.Bold; } if (_italic) { style |= FontStyle.Italic; } if (_underline) { style |= FontStyle.Underline; } textFont = new Font(_fontName, (float)_fontSize, style); textBrush = new SolidBrush(_foreColor); //写入位图文件内容 g.DrawString(_text, textFont, textBrush, new RectangleF(0, 0, _width, _height), textFormat); }以上是自己的一个控件的代码 希望对你有帮助。 IntPtr dc2 = Function.GetWindowDC(Function.GetDesktopWindow()); Function.BitBlt(dc1, 0, 0, Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height, dc2, 0, 0,13369376); 这两句话不对!! gyf19(秋天的云): 我的代码没问题, 换成4位或8位后在第一行出错, 与后面的无关. update Winfrom中两个Radiobutton 怎么做条件查询 C# 用DLL封装MDI子窗体 C#网络编程高手请进 c#(window程序)如果备份和恢复数据库 ?? 点击提交按钮没有反应 c# String data, right truncated. C#编写ActiveX控件问题。IE中无法触发事件 请问如何在C#中调用外部程序啊? Bitmap.save 的问题。 如何将windows窗体上输入的信息写进数据库呢?同时还可以对数据库进行查询,修改,删除操作 求QQ端口号
Graphics g = null; StringFormat textFormat = null;
Font textFont = null;
Brush textBrush = null;
Brush backBrush = null; try
{
// 初始参数
InitializeParameters(request); // 创建位图
image = new Bitmap(_width, _height, PixelFormat.Format32bppArgb);
g = Graphics.FromImage(image); // 创建画笔
backBrush = new SolidBrush(_backColor);
g.FillRectangle(backBrush, 0, 0, _width, _height); if (_text.Length != 0)
{
// 创建位图内容
textFormat = new StringFormat(StringFormatFlags.NoWrap);
textFormat.Alignment = _horizontalAlign;
textFormat.LineAlignment = _verticalAlign; FontStyle style = FontStyle.Regular;
if (_bold)
{
style |= FontStyle.Bold;
}
if (_italic)
{
style |= FontStyle.Italic;
}
if (_underline)
{
style |= FontStyle.Underline;
}
textFont = new Font(_fontName, (float)_fontSize, style);
textBrush = new SolidBrush(_foreColor); //写入位图文件内容
g.DrawString(_text, textFont, textBrush, new RectangleF(0, 0, _width, _height), textFormat);
}
以上是自己的一个控件的代码 希望对你有帮助。
Function.BitBlt(dc1, 0, 0, Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height, dc2, 0, 0,13369376);
这两句话不对!!
我的代码没问题, 换成4位或8位后在第一行出错, 与后面的无关.