Nasıl yapılır: GDI+ ile Resim İşleme
uygulamalarınızda bulunan dosyalar gibi görüntüleri işlemek için GDI+ kullanabilirsiniz. Bunu, bir sınıfın yeni bir nesnesi oluşturarak (gibi Image Bitmap ), Graphics kullanmak istediğiniz çizim yüzeyine başvuran bir nesne oluşturarak ve DrawImage nesnesinin yöntemini çağırarak yapabilirsiniz Graphics . Resim, grafik sınıfı tarafından temsil edilen çizim yüzeyine göre boyanacaktır. tasarım zamanında görüntü dosyalarını oluşturmak ve düzenlemek için görüntü düzenleyicisini kullanabilir ve çalışma zamanında bunları GDI+ işleyebilirsiniz. Daha fazla bilgi için bkz. simgeler Için görüntü düzenleyici.
GDI+ bir görüntüyü işlemek için
Göstermek istediğiniz görüntüyü temsil eden bir nesne oluşturun. Bu nesne, veya gibi öğesinden devralan bir sınıfın üyesi olmalıdır Image Bitmap Metafile . Örnek gösterilmektedir:
' 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));Kullanmak istediğiniz Graphics çizim yüzeyini temsil eden bir nesne oluşturun. Daha fazla bilgi için bkz. nasıl yapılır: çizim Için grafik nesneleri oluşturma.
' 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();DrawImageGörüntüyü işlemek için grafik nesnenizin ' i çağırın. Çizilecek görüntüyü ve çizileceği koordinatları belirtmeniz gerekir.
g.DrawImage(myBitmap, 1, 1)g.DrawImage(myBitmap, 1, 1);g->DrawImage(myBitmap, 1, 1);