プロが教える店舗&オフィスのセキュリティ対策術

VB6では、ピクチャーボックスに点を打つ場合は、

Picture1.PSet (100, 50)

で良かったのですが、VB9ではどのようにするのでしょうか?

また、.NETの画像について詳しく書かれているサイトはありますか

A 回答 (2件)

/* VB.NETだったの忘れてたorz */



Public Class Form1
Inherits System.Windows.Forms.Form
'あらたなBitmapオブジェクトを生成した方法は
'Q4045416
'などを参考に。

Private Picturebox1 As System.Windows.Forms.PictureBox = Nothing
Private b1 As New System.Drawing.Bitmap(500, 500)

Public Sub New()
Me.Width = 800
Me.Height = 600

Picturebox1 = New System.Windows.Forms.PictureBox()
Picturebox1.Top = 0
Picturebox1.Left = 50
Picturebox1.Width = 500
Picturebox1.Height = 500
Picturebox1.BackColor = System.Drawing.Color.White
Me.Controls.Add(Picturebox1)

b1.SetPixel(100, 50, System.Drawing.Color.Red)

Picturebox1.Image = b1
End Sub


End Class
Class Q4105537A
Public Shared Sub Main(args As String())
Dim f As New Form1()
f.ShowDialog()
End Sub
End Class
    • good
    • 1

/*


SetPixelだけ何故かSystem.Drawing.Bitmap側のメソッドなんだよな・・・。線を引きたいとかの場合,Q4105537参照。

実を言うといちいち書くの面倒くさかったので
殆どQ4105537のコピーだ。
*/

namespace Q4238973A
{
public class Form1:System.Windows.Forms.Form
{
//あらたなBitmapオブジェクトを生成した方法は
//Q4045416
//などを参考に。

private System.Windows.Forms.PictureBox Picturebox1 = null;
private System.Drawing.Bitmap b1 = new System.Drawing.Bitmap(500,500);

public Form1(){
this.Width = 800;
this.Height = 600;

Picturebox1 = new System.Windows.Forms.PictureBox();
Picturebox1.Top = 0;
Picturebox1.Left = 50;
Picturebox1.Width = 500;
Picturebox1.Height = 500;
Picturebox1.BackColor = System.Drawing.Color.White;
this.Controls.Add(Picturebox1);

b1.SetPixel(100,50,System.Drawing.Color.Red);
Picturebox1.Image = b1;

}


}
class Q4105537A{
public static void Main(string[] args){
Form1 f = new Form1();
f.ShowDialog();
}
}
}
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!

このQ&Aを見た人はこんなQ&Aも見ています