質問編集履歴
1
ソースを追加しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,36 @@
|
|
1
1
|
Resourcesフォルダーの中にある画像ファイルを、
|
2
2
|
プログラム(C#)で実装させて表示する方法はありますか?
|
3
3
|
|
4
|
-
よろしくお願いします
|
4
|
+
よろしくお願いします
|
5
|
+
|
6
|
+
現在は、\bin\Debugの直下にiconフォルダーを作成して、
|
7
|
+
クラス化にしてそこから呼び出して表示しています
|
8
|
+
|
9
|
+
それを、Resourcesの中にある.pngファイルを表示させるように変更したい
|
10
|
+
|
11
|
+
|
12
|
+
クラス側
|
13
|
+
public static Bitmap picImage(PictureBox pic, string strFile, int intX, int intY, int intWidth, int intHeight)
|
14
|
+
{
|
15
|
+
//描画先とするImageオブジェクトを作成する
|
16
|
+
Bitmap canvas = new Bitmap(pic.Width, pic.Height);
|
17
|
+
//ImageオブジェクトのGraphicsオブジェクトを作成する
|
18
|
+
Graphics g = Graphics.FromImage(canvas);
|
19
|
+
|
20
|
+
//画像ファイルを読み込んで、Imageオブジェクトとして取得する
|
21
|
+
Image img = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + @"icon\" + strFile);
|
22
|
+
|
23
|
+
//画像をcanvasの座標(0, 0)の位置に描画する
|
24
|
+
g.DrawImage(img, intX, intY, intWidth, intHeight);
|
25
|
+
//Imageオブジェクトのリースを解放する
|
26
|
+
img.Dispose();
|
27
|
+
|
28
|
+
//Graphicsオブジェクトのリソースを解放する
|
29
|
+
g.Dispose();
|
30
|
+
|
31
|
+
return canvas;
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
呼び出す側
|
36
|
+
this.picCard.Image = クラス名.picImage(picCard, "ファイル名.png", 0, 0, 700, 80);
|