Laman

Jumat, 01 April 2011

Menyimpan gambar dari picturebox di C# (C Sharp)

Pada tutorial ini akan dibahas bagaimana cara suatu gambar yang berada di picturebox disimpan ke directory yang diinginkan. Beberapa komponen yang digunakan seperti saveFileDialog, sebuah picture box  dan dua bauh button seperti pada gambar disamping. Untuk  membuat project, siapkan terlebih dahulu project kosong,  klik file pilih new project setelah muncul kotak dialog name silahkan isi nama project pada kotak tersebut. Untuk langkah langkah selanjutnya ikuti instruksi dibawah ini.

langkah 1 : Setelah project kosong dibuat, silahkan tambahakn dua komponen button, satu picturebox dan satu kotak dialogSaveFileDialog, atur dan tata sedemikian rupa sehingga tampilannya seperti pada gambar diatas
langkah 2 : Double klik pada button satu (button yang berlabelkan Load Image) untuk membangkitkan event single klik pada button tersebut. setelah mincul jendela source code event single klik tambahkan code dibawah ini pada button tersebut
pictureBox1.ImageLocation = @"c:\\okfanWork\\darah5.jpg";

sebelumnya file gambar berformat jpg yang bernama darah5.jpg harus diletakan di direktori C
langkah 3 : Lakukan hal yang sama pada button2 (button yang berlabelkan Save) untuk membangkitkan event single klik pada button tersebut, masukan source code berikut ini
if (DialogResult.OK == saveFileDialog1.ShowDialog())
{                
  pictureBox1.Image.Save(saveFileDialog1.FileName.ToString());
}

langlah 4 : Done. program selesai. Jika langkah langkah diatas dilakukan dengan benar, maka saat program dijalankan  program meminta untuk meload data gambar dalam kasus ini data gambar ada di direktori C:\. Setelah data gambar berhasil di load program mampu melakukan penyimpanan gambar yang ada dipicturebox tersebut ke direktori yang ditentukan oleh user dengan menekan tombol save.  Berikut ini preview program yang dirunning

 Gambar 2 Preview ketika program meload data gambar ke PictureBox

Untuk lebih jelasnya dalam memahami tutorial ini silahkan downlaod contoh programnya disini, dan juga download projectnya disini Beriktu ini daftar link untuk download semua file yang dibutuhkan dalam tutorial ini 
Download program disini
Download project disini
Download File Gambar disini
For more information contact on informasi@csharp-indonesia.com

pandauan download : klik link download yang disediaan diatas, setelah itu akan muncul halaman adf.ly, tunggu beberapa detik sampai pada pojok kanan atas muncul tulisan skip ad. klik tombol tersebut ,setelah itu akan muncul halaman ziddu, silahkan klik pada button download yang muncul pada halaman ziddu
NB : Dalam tutorial ini program ditulisa menggunakan IDE Visual studio 2010. dengan target framework 4.0.Sehingga minimal komputer harus terinstal windows 7 untuk bisa menjalankan program *.exe nya, Atau windows xp yang sudah di instal netFrameWork 4.0. Sedangkan untuk membuka projectnya mau tidak mau harus menginstal microsoft visual studio 2010.

11 komentar:

  1. mas klw kita mau nampilin image dari datagridview ke picturebox gimana y mas???

    klw kita mau nampilin data biasa kan
    misalnya: txtIdPengeluaran.Text = dataGridViewPengeluaran.CurrentRow.Cells[0].Value.ToString();
    nah klw mau nampilin image gimana y mas...tolong krm k email saya y mas....
    mika.ardo@yahoo.com

    BalasHapus
  2. sepengetahuan kami. textBox.text tidak support untuk menampilkan gambar. Jika ingin menampilkan gambar pakai komponen PICTUREBOX atau DATAGRIDVIEW.

    BalasHapus
  3. maaf gan pemula....
    mau tanya bisa gak nyimpan video dari C# ke database mysql...

    BalasHapus
  4. as well as for the upcoming Fall-Winter. The cocktail event took place at Edelman PR office (the PR sunglass hut firm that handles Oakley’s public relations in Canada) at 150 Bloor Street West in Toronto. Fashion media from Toronto could get a sneak peak at Oakley’s high performance and versatile fitness apparel and sunglasses, as well as their fashionable Summer and Fall lifestyle oakley military apparel line for both men and women. Guests could view the latest fashion and fitness trends, learn about unique Oakley apparel technology, and find out about the newest pieces from Oakley’s brand representatives.Oakley sunglasses are designed with a unique technology that provides more oakley gascan efficiency during sports activities, like jogging. Most of the times, when we go in the park for jogging, it’s not that comfortable for us to wear sunglasses (even though it would be useful), due to the fact that our face sweats five minutes oakley prescription sunglasses into jogging and the sunglasses slip off our nose. One of the styles of Oakley sunglasses are designed in such a way that not only don’t they fall off the face, but they actually stick to the skin when sweaty, making wearing sunglasses oakley holbrook during jogging more comfortable and efficient.
    Sunglasses and their accessories can be a great holiday gift for the hard-to-please or for the person who has everything. Gift certificates to any of these stores are available in any denomination for purchase. Give a gift oakley sports sunglasses that gives them the control, while giving you the ease with shopping and peace of mind.Glasses.com, an online retailer of prescription and non-prescription designer glasses and sunglasses, is having a huge sale on Cyber Monday, December 1, 2014 (expires 11:59 p.m. MST)! Hurry orange oakley sunglasses and take advantage of this one day only secret sale at Glasses.com and enjoy up to 70 percent off! Choose from a wide-range of styles and designer brands such as, but not limited to: Burberry, Kate Spade New York, Lanvin, Maui Jim, Oakley, radar oakley sunglasses Persol and Ray-Ban!
    $25 - $75 Price Point

    BalasHapus
  5. vous pouvez les essayer dolabuy hermes aller sur ce site Web YSL Dolabuy parcourez ce site Web sacs de répliques de luxe

    BalasHapus