日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

图片框

發布時間:2024/1/8 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 图片框 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

圖 片 框 圖片框

1.圖片框

圖片
Image:抽象類,圖像的統稱
Bitmap:具體類,位圖,像素圖
示例:

Bitmap img = new Bitmap("c:\\lexample\\123.jpg"); int w = img.Width; int h= img.Height;

PictureBox圖片框控件:用于顯示一個圖片
設置縮放模式

picbox.SizeMode =PictureBoxSizeMode.Zoom;

顯示圖片

picbox.Image = img;

或者加載圖片

picbox.Load("c: \ \example \ \123.jpg");

1圖片文件的路徑,用windows路徑(反斜杠)

"c:\\example\\123.jpg"

"c:/example/123.jpg”不支持

using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;namespace WinForm基礎22 {public partial class Form1 : Form{public Form1(){InitializeComponent();Bitmap img = new Bitmap("E:\\cat.png");int w = img.Width;int h = img.Height;pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;pictureBox1.Image = img;}} }

2.圖片資源

Bitmap:具體類,位圖,像素圖
圖片的來源:

  • 本地文件,如"E:\cat.png"
  • 資源文件
  • 網絡文件,如http://qq.cn/img/cat.jpg

資源文件:

Properties \ Resources.resx

可以添加字符串、位圖、圖標、音頻等類型的資源


添加資源:
1 雙擊Resources.resx,打開資源編輯器
2 添加資源 | 添加現有文件
選擇一張圖片文件
3 修改資源名稱
4 使用資源

Bitmap photo = Properties.Resources.Img_Cat;

using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;namespace WinForm基礎22 {public partial class Form1 : Form{public Form1(){InitializeComponent();Bitmap img = Properties.Resources.Img_Cat;pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;pictureBox1.Image = img;}} }

在程序打包時,資源數據被打包到EXE程序中

總結

以上是生活随笔為你收集整理的图片框的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。