Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Anda dapat menggunakan GDI+ untuk merender gambar yang ada sebagai file di aplikasi Anda. Anda melakukan ini dengan membuat objek baru dari kelas Image (seperti Bitmap), membuat objek Graphics yang mengacu pada permukaan gambar yang ingin Anda gunakan, dan memanggil metode DrawImage objek Graphics. Gambar akan dicat ke permukaan gambar yang diwakili oleh kelas grafis. Anda dapat menggunakan Editor Gambar untuk membuat dan mengedit file gambar pada waktu desain, dan merendernya dengan GDI+ pada waktu proses. Untuk informasi selengkapnya, lihat Editor Gambar untuk Ikon.
Untuk merender gambar dengan GDI+
Buat objek yang mewakili gambar yang ingin Anda tampilkan. Objek ini harus menjadi anggota kelas yang mewarisi dari Image, seperti Bitmap atau Metafile. Contoh ditampilkan:
' Uses the System.Environment.GetFolderPath to get the path to the ' current user's MyPictures folder. Dim myBitmap as New Bitmap _ (System.Environment.GetFolderPath _ (System.Environment.SpecialFolder.MyPictures))// Uses the System.Environment.GetFolderPath to get the path to the // current user's MyPictures folder. Bitmap myBitmap = new Bitmap (System.Environment.GetFolderPath (System.Environment.SpecialFolder.MyPictures));// Uses the System.Environment.GetFolderPath to get the path to the // current user's MyPictures folder. Bitmap^ myBitmap = gcnew Bitmap (System::Environment::GetFolderPath (System::Environment::SpecialFolder::MyPictures));Buat objek Graphics yang mewakili permukaan gambar yang ingin Anda gunakan. Untuk informasi selengkapnya, lihat Cara: Membuat Objek Grafis untuk Menggambar.
' Creates a Graphics object that represents the drawing surface of ' Button1. Dim g as Graphics = Button1.CreateGraphics// Creates a Graphics object that represents the drawing surface of // Button1. Graphics g = Button1.CreateGraphics();// Creates a Graphics object that represents the drawing surface of // Button1. Graphics^ g = button1->CreateGraphics();Gunakan DrawImage dari objek grafis Anda untuk merender gambar. Anda harus menentukan gambar yang akan digambar, dan koordinat tempat gambar akan digambar.
g.DrawImage(myBitmap, 1, 1)g.DrawImage(myBitmap, 1, 1);g->DrawImage(myBitmap, 1, 1);
Lihat juga
.NET Desktop feedback