如题:
求任何可能解决该问题的方法:
我的图片是运行时加载的,加载路径是通过数据库读取的。。我窗体上有个背景图,然后几个PICBOX 。。背景图加载很快,而且图也很大。。
但是这几个PICBOX加载时就能看到延时,就跟网页刷新一样。图片我设了透明背景,,但是两张图片重叠的时候就能看到方形的背景了。
求任何可能解决该问题的方法:
求任何可能解决该问题的方法:
我的图片是运行时加载的,加载路径是通过数据库读取的。。我窗体上有个背景图,然后几个PICBOX 。。背景图加载很快,而且图也很大。。
但是这几个PICBOX加载时就能看到延时,就跟网页刷新一样。图片我设了透明背景,,但是两张图片重叠的时候就能看到方形的背景了。
求任何可能解决该问题的方法:
2 如果是 你必须设置 显示你图形的PICTUREBOX的父容器是 背景的PICTUREBOX..透明只是对父容器的颜色.而不是同级覆盖在下面控件的颜色.也就是说 backPictureBox.Controls.Add(PictureBox) 这样来做.
3 速度慢..这个问题有很多.一时间说不清楚..你可以这样考虑 使用Gdi+ 先绘制背景图.然后绘制张长图片..绘制到一个BITMAP 然后再显示到界面..这样也可以解决透明的问题.
这个和你用Paint() 没关系 Paint里的方法你可以写成变量形式的.
http://topic.csdn.net/u/20090414/15/fabf4268-4b43-4133-b89b-9807be056444.html
http://www.itstrike.cn/Home.mvc/Search/?key=GDI
2008-07-13 15:47
private void picturebox1_Paint(object sender, PaintEventArgs e)
{
foreach (Control C in this.Controls)
{ if (C is Label)
{ Label L = (Label)C; L.Visible = false; e.Graphics.DrawString(L.Text, L.Font, new SolidBrush(L.ForeColor), L.Left - picturebox1.Left, L.Top - picturebox1.Top); } } }
参考
参考
{
using (FileStream fs = new FileStream(baseFile, FileMode.Open, FileAccess.Read))
{
Bitmap img = (Bitmap)Image.FromStream(fs, false, false);
int width = img.Width;
int height = img.Height; Bitmap resultbmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
ColorPalette palette = resultbmp.Palette;
int n = 0;
foreach (Color tc in img.Palette.Entries)
{
palette.Entries[n] = Color.FromArgb(255, tc);
n++;
} palette.Entries[colorIndex] = Color.FromArgb(0, palette.Entries[colorIndex]);
resultbmp.Palette = palette; //now to copy the actual bitmap data
BitmapData src = img.LockBits(
new Rectangle(0, 0, width, height),
ImageLockMode.ReadOnly,
img.PixelFormat); BitmapData dst = resultbmp.LockBits(
new Rectangle(0, 0, width, height),
ImageLockMode.WriteOnly,
resultbmp.PixelFormat); byte* pSrc = (byte*)src.Scan0.ToPointer();
byte* pDst = (byte*)dst.Scan0.ToPointer();
int offset = src.Stride - width; //steps through each pixel
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
pDst[0] = pSrc[0];
pDst++;
pSrc++;
}
pDst += offset;
pSrc += offset;
} //unlock the bitmaps
img.UnlockBits(src);
resultbmp.UnlockBits(dst); resultbmp.Save(outputFile, ImageFormat.Gif); img.Dispose();
resultbmp.Dispose();
}
}