小编rag*_*ghu的帖子

使用打开文件对话框将位图图像加载到窗体中!

我需要使用打开的文件对话框打开窗口中的位图图像(我将从驱动器加载它).图像应该放在图片框中.这里有一些代码我试过但有错误!

 private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title = "Open Image";
            dlg.Filter = "bmp files (*.bmp)|*.bmp";

            if (dlg.ShowDialog() == DialogResult.OK)
            {                     
            PictureBox PictureBox1 = new PictureBox();                    
                PictureBox1.Image(dlg.FileName);
            }

            dlg.Dispose();
        }
Run Code Online (Sandbox Code Playgroud)

.net c# bitmap picturebox winforms

15
推荐指数
3
解决办法
12万
查看次数

printf函数的问题?

我写了以下程序

 #include <stdio.h>

 main()
 {
 int i = 2;
 float c = 4.5;
 printf("%d\n",c);
 printf("%f\n",i);
 return 0;
 }
Run Code Online (Sandbox Code Playgroud)

虽然我知道这是错误的做法,当我运行程序时,我得到了答案

0
4.500000
Run Code Online (Sandbox Code Playgroud)

但是当我用这种方式交换printf语句时

#include <stdio.h>

main()
{
int i = 2;
float c = 4.5;
printf("%f\n",i);
printf("%d\n",c);
return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出是

0.000000
0
Run Code Online (Sandbox Code Playgroud)

我无法理解发生了什么,任何人都会解释我.

c printf casting

2
推荐指数
2
解决办法
1897
查看次数

如何使用c#撤消绘制操作

我在picturebox中加载了一个图像.我通过鼠标点击事件对图像执行绘制操作.当点击鼠标时,它会绘制一个黑色的小矩形区域.现在我想实现撤消操作这个.当我点击一个按钮时,最后的绘画操作应该被撤消.这是我的绘画操作代码..

      private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
    {

            rect.Width = 0;
            rect.Height = 0;
            pictureBox1.Invalidate();


            int radius = 10; //Set the number of pixel you want to use here
            //Calculate the numbers based on radius
            int x0 = Math.Max(e.X - (radius / 2), 0),
                y0 = Math.Max(e.Y - (radius / 2), 0),
                x1 = Math.Min(e.X + (radius / 2), pictureBox1.Width),
                y1 = Math.Min(e.Y + (radius / 2), pictureBox1.Height);
            Bitmap bm = pictureBox1.Image as Bitmap; //Get the bitmap (assuming it is …
Run Code Online (Sandbox Code Playgroud)

.net c#

1
推荐指数
1
解决办法
4908
查看次数

标签 统计

.net ×2

c# ×2

bitmap ×1

c ×1

casting ×1

picturebox ×1

printf ×1

winforms ×1