| Article | 
|---|
| PictureBox’ta Random Resim GösterimiMerhaba arkadaşlar, bu makalemizde images klasöründe bulunan resimleri random olarak PictureBox nesnesinde göstereceğiz. Formumuza PictureBox ve Timer ekleyeceğiz.
 | 
| GridView Nesnesindeki Verileri ve Resimleri Excele AktarmakMerhaba arkadaşlar bu makalemizde GridView nesnesindeki verileri resimler ile birlikte excel dosyaya aktaracağız.
 | 
| GridView Nesnesinde Dinamik Olarak Resim GösterimiMerhaba arkadaşlar bu makalemizde GridView nesnesine dinamik olarak resim ve string girişi yapacağız. Şimdi projemize 3 adet TextBox, 1 adet FileuPload ve GridView ekleyelim.
 | 
| Resim Üzerine Yazı YazmakBu makalemizde FileUpload ile resimler klasörüne yükleyeceğimiz resimin üzerine dikey olarak yazı yazacağız...
 | 
| Labele Resim EklemeBu makalemizde label nesnesinde resim göstereceğiz. Aşağıdaki şekli inceleyin.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();
            Label label1 = new System.Windows.Forms.Label(); 
            this.SuspendLayout();
            label1.Image = new Bitmap("C:\\image.jpg");
            label1.ImageAlign = System.Drawing.ContentAlignment.TopRight;
            label1.Location = new System.Drawing.Point(20, 9);
            label1.Name = "label1";
            label1.Size = new System.Drawing.Size(100, 128);
            label1.TabIndex = 0;
            label1.Text = "Labele resim ekleme..Bahadır ŞAHİN";
            label1.ForeColor = Color.White;
            this.Controls.Add(label1);
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Text = "Labele Resim Ekleme";
            this.ResumeLayout(false);
        }
   }
}
//Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN
 | 
| Panelde Resimin ScrollBarlı Olarak GösterimiPanelde resim yatay ve dikey scrollbar lı şekilde gösterimini sağlayacağız. Şekil 1 i inceleyiniz.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        Panel panel1 = new System.Windows.Forms.Panel();
        public Form1()
        {
            InitializeComponent();
            
            this.SuspendLayout();
            panel1.AutoScroll = true;
            panel1.BackgroundImage = new Bitmap("C:\\pic1.bmp");
            panel1.Location = new System.Drawing.Point(13, 13);
            panel1.Size = new System.Drawing.Size(267, 243);
            AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            ClientSize = new System.Drawing.Size(292, 268);
            Controls.Add(panel1);
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false); panel1.AutoScrollMinSize = panel1.BackgroundImage.Size;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
           
            int midX = panel1.AutoScrollMinSize.Width / 2;
            int midY = panel1.AutoScrollMinSize.Height / 2;
            int halfSizeX = panel1.Size.Width / 2;
            int halfSizeY = panel1.Size.Height / 2;
            int startPosX = midX - halfSizeX;
            if (startPosX < 0) startPosX = 0;
            int startPosY = midY - halfSizeY;
            if (startPosY < 0) startPosY = 0;
            panel1.AutoScrollPosition = new Point(startPosX, startPosY);
        }
    }
}
//Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN
 | 
| Resminizin Boyutunu DeğiştirinPictureBox taki resmin, trackbar daki değere göre boyutunu değiştireceğiz. 
Formunuza 1 adet PictureBox, TrackBar,Button ve OpenFileDialog nesnesi ekleyin. Aşağıdaki şekilleri inceleyin.
public partial class Form1 : Form
    {
        int y;
        int x;
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
             DialogResult result = openFileDialog1.ShowDialog();
                     
            if (result == DialogResult.OK)
            {
                pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            trackBar1.Maximum = 10;
            trackBar1.Minimum = 1;
            trackBar1.TickFrequency = 1;
            x = pictureBox1.Width;
            y = pictureBox1.Height;
           
        }
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            pictureBox1.Width = x * trackBar1.Value;
            pictureBox1.Height = y * trackBar1.Value;
        }
    }
//Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN
 | 
| Formun Arka Planına Bitmap Resim EklemeBu örnekte formun arka planına bitmap resim ekleyeceğiz. Formunuzun FormBorderStyle özelliğini None seçin.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
       Bitmap resim = new Bitmap("resim.jpg");
      
        public Form1()
        {
            InitializeComponent();
            this.Paint += new System.Windows.Forms.PaintEventHandler(Form1_Paint);
        }
       
        private void Form1_Paint(object sender, PaintEventArgs e) 
{ 
   Graphics g = e.Graphics; 
   Rectangle mainRect = new Rectangle(0, 0, 695, 278); 
   Region mainRegion = new Region(mainRect); 
   e.Graphics.SetClip(mainRegion, CombineMode.Replace); 
  
   GraphicsPath myPath = new GraphicsPath(); 
  
   Region ExcludeRegion3 = new Region(myPath); 
   e.Graphics.ExcludeClip(ExcludeRegion3); 
 
   e.Graphics.DrawImage(resim, 0, 0, 495,278); 
   
   e.Graphics.ResetClip(); 
}
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Size = new System.Drawing.Size(500,280);
        } 
    }
}
//Bir sonraki makalede görüşmek üzere. Bahadır
 | 
| RichTextBox a Resim EklemeBu örnekte RichTextBox ın içine resim ekleyeceğiz.Clipboard metodundan yararlanacağız.
Aşağıdaki şekilleri inceleyin.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim img As Image = Image.FromFile("C:\resim.jpg")
        Clipboard.SetImage(img)
        Me.RichTextBox1.Paste()
    End Sub
Bir sonraki makalede buluşmak üzere. Bahadır ŞAHİN
 | 
| Resim Boyunu ÖğrenmekResimlerimizin boyutunu; yazacağımız küçük bir kod parçasıyla öğrenebiliriz. Formunuza 1 adet buton ekleyin. Aşağıdaki şekli inceleyin.
Imports System.IO
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim buffer As Byte()
        Dim fs As FileStream = New FileStream("C:\ornek.jpg", FileMode.Open, FileAccess.Read)
        ReDim buffer(fs.Length)
        fs.Read(buffer, 0, fs.Length)
        fs.Close()
        MessageBox.Show("Resim Boyut(Byte cinsinden): " & buffer.Length)
    End Sub
End Class
Bir sonraki makalede buluşmak üzere. Bahadır ŞAHİN
 | 
| Web Sitesinden Resim Download EtmekBir önceki makalede text dosyanın indirilmesini incelemiştik. Bu öernektede sitedeki resimlerin nasıl indirileceğini göreceğiz. Sayfaya 1 adet button ekleyin.
 |