image

C# (C Sharp) veya Java ile ilgili konuları buraya yazabilirsiniz.
Cevapla
Kullanıcı avatarı
birisi
Üye
Mesajlar: 17
Kayıt: 12 Haz 2003 08:46
Konum: istanbul
İletişim:

image

Mesaj gönderen birisi »

Merhaba uzun bir aradan sonra hemde oldukça uzun bir aradan sonra tekrar geldim. Askerlik olayını halletmem gerektide.

ben yokken teknoloji biraz değişmiş C# diye bir şey Türkiyede de kullanılır hale gelmiş. Tabi bizde de bir merak aldı uğraşıyoruz. Ama biraz takıldık

Şöyleki: bir image nesnemiz var (Picturebox1.image) buradaki her pikseli bir diziye atıp daha sonra bunun tersini alıp başka bir image atmak istiyorum. RotateFlip* 'ten bahsetmiyorum. başka amaçlar için kullanılacak. Burada istediğim diziye nasıl atıp nasıl diziden geri alabilirim.
Kullanıcı avatarı
lazio
Moderator
Mesajlar: 1526
Kayıt: 11 Tem 2003 04:55
Konum: İstanbul

Mesaj gönderen lazio »

tersini almaktan neyi kastettiğini anlayamadım ama
pictureBox1 taki resmi diske kaydedip (pictureBox1.Image.Save())
byte olarak okuyup diziye atsan üzerinde işlem yapabilirsin diye düşünüyorum..
Resim

..::|YeşilMavi|::..
Kullanıcı avatarı
birisi
Üye
Mesajlar: 17
Kayıt: 12 Haz 2003 08:46
Konum: istanbul
İletişim:

Mesaj gönderen birisi »

diskten byte byte okuduk diyelim. daha sonra her byte'ı 255'ten çıkartırsak tersini almış oluruz veya şöylede bir ters alma olabilir:

yeni[n]=eski[1];
yeni[n-1]=eski[2];
........
yeni[1]=eski[n];

şeklinde

böylece görüntünün başını aşağıya çevirmiş olmak gibi farketmez.

asıl sormak istediğim. byte olarak okuduktan sonra bunu tekrar diske yazmadan picturebox1.image içerisine çizebilirmiyim. ? pixel pixel .

kusura bakmayın kafam biraz dağınık derdimi tam olarak anlatamıyorum. :(
Kullanıcı avatarı
mege
Admin
Mesajlar: 2360
Kayıt: 05 Şub 2004 04:32
Konum: Beşiktaş
İletişim:

Mesaj gönderen mege »

viewtopic.php?p=18311#18311

Kod: Tümünü seç

  b1 := Image1.Picture.Bitmap;
  for y := 0 to b1.Height - 1 do
  begin
    c1 := b1.Scanline[y];
    s:='';
    for x := 0 to (b1.Width - 1)*3 do
       if (x mod 3) = 2 then
         s:= s+ '<span style="color: rgb('+ inttostr(c1[x])+','+inttostr(c1[x])+','+inttostr(c1[x])+');">M</span>';
    list.Add(s+'<BR>');
  end;
benzer bişrşey sanırım ama burda renkler karakterlere basılır
.-.-.-.-.-.-.-. ^_^
Kullanıcı avatarı
lazio
Moderator
Mesajlar: 1526
Kayıt: 11 Tem 2003 04:55
Konum: İstanbul

Mesaj gönderen lazio »

çok fazla inceleyemedim ama aşağıdaki fikir verir sanırım

Kod: Tümünü seç

[C#] 
private void PopulateListView()
{
    ListView1.Width = 270;
    ListView1.Location = new System.Drawing.Point(10, 10);

    // Declare and construct the ColumnHeader objects.
    ColumnHeader header1, header2;
    header1 = new ColumnHeader();
    header2 = new ColumnHeader();

    // Set the text, alignment and width for each column header.
    header1.Text = "File name";
    header1.TextAlign = HorizontalAlignment.Left;
    header1.Width = 70;

    header2.TextAlign = HorizontalAlignment.Left;
    header2.Text = "Location";
    header2.Width = 200;

    // Add the headers to the ListView control.
    ListView1.Columns.Add(header1);
    ListView1.Columns.Add(header2);

    // Populate the ListView.Items property.
    // Set the directory to the sample picture directory.
    System.IO.DirectoryInfo dirInfo = 
        new System.IO.DirectoryInfo(
        "C:\\Documents and Settings\\All Users" +
        "\\Documents\\My Pictures\\Sample Pictures");
    

    // Get the .jpg files from the directory
    System.IO.FileInfo[] files = dirInfo.GetFiles("*.jpg");

    // Add each file name and full name including path
    // to the ListView.
    if (files != null)
    {
        foreach ( System.IO.FileInfo file in files )
        {
            ListViewItem item = new ListViewItem(file.Name);
            item.SubItems.Add(file.FullName);
            ListView1.Items.Add(item);
        }
    }
}

private void InitializePictureBox()
{
    PictureBox1 = new PictureBox();

    // Set the location and size of the PictureBox control.
    this.PictureBox1.Location = new System.Drawing.Point(70, 120);
    this.PictureBox1.Size = new System.Drawing.Size(140, 140);
    this.PictureBox1.TabStop = false;

    // Set the SizeMode property to the StretchImage value.  This
    // will shrink or enlarge the image as needed to fit into
    // the PictureBox.
    this.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;

    // Set the border style to a three-dimensional border.
    this.PictureBox1.BorderStyle = BorderStyle.Fixed3D;

    // Add the PictureBox to the form.
    this.Controls.Add(this.PictureBox1);

}


private void ListView1_MouseDown(object sender, MouseEventArgs e)
{

    ListViewItem selection = ListView1.GetItemAt(e.X, e.Y);

    // If the user selects an item in the ListView, display
    // the image in the PictureBox.
    if (selection != null)
    {
        PictureBox1.Image = System.Drawing.Image.FromFile(
            selection.SubItems[1].Text);
    }
}
http://www.msdn.com dan daha detaylı bilgi alabilirsin
Resim

..::|YeşilMavi|::..
Kullanıcı avatarı
birisi
Üye
Mesajlar: 17
Kayıt: 12 Haz 2003 08:46
Konum: istanbul
İletişim:

Mesaj gönderen birisi »

aslında şöyle bir kod yazdım

Kod: Tümünü seç

		private void button5_Click(object sender, System.EventArgs e)
		{
			//openFileDialog1.ShowDialog();
			Bitmap res=new Bitmap (pictureBox1.Image );
			Bitmap res2=new Bitmap(res) ;
			Color[,] renkler=new Color [res.Size.Height  , res.Size.Width  ];
			int i,j;
			for ( i=0;i<res.Size.Height-1  ;i++)
				for ( j=0;j<res.Size.Width -1 ; j++)
				{
					renkler[i,j]=res.GetPixel (j,i);
				}
			for (i=res.Size.Height-1  ;i>0;i--)
				for (j=res.Size.Width -1 ;j>0;j--)
				{
					res2.SetPixel (res.Size.Width-j,res.Size.Height-i,renkler[i,j]);

				}
			pictureBox2.Image=res2;


		}

ancak bu işlem 4 saniyeye yakın suruye ve CPU tavan yapıyo. :duvar:

bunu hızlandırmam ve CPU'yu çok az yormam gerek çünkü çalışacağı bilgisayar zaten yoğun işler yapıyo olacak.

acaba bir win32 dll yazıp yapabilirmiyim diye düşünüyorum. ama onuda ben beceremiyorum :kup: tabi farklı düşüncelere açığım
Kullanıcı avatarı
birisi
Üye
Mesajlar: 17
Kayıt: 12 Haz 2003 08:46
Konum: istanbul
İletişim:

Galiba Hala Bende Umit Var

Mesaj gönderen birisi »

Tamam Tamam hallettim :D

En iyisi C++ kullanmakmış. C++ ile bir dll yazmaya çalıştım biraz kafasını gözünü yardım ama oldu. Deneme yapababilmek için gerekli Kodu aşağıya gönderiyorum. İlginiz için teşekkürler.

Kod: Tümünü seç

				 HWND hwndkaynak=(HWND)pictureBox1->Handle.ToInt32();
				 HDC hdckaynak;
				 
				 hdckaynak=GetWindowDC(hwndkaynak);
				 HDC hMemDc=CreateCompatibleDC(hdckaynak);
				 RECT r;
				 GetWindowRect(hwndkaynak,&r);
				 SIZE size;
				 size.cx=r.right-r.left;
				 size.cy=r.bottom-r.top;
				 HBITMAP hBitmap=CreateCompatibleBitmap(hdckaynak,size.cx,size.cy);
				 if(hBitmap)
				 {
					 HBITMAP hOld=(HBITMAP)SelectObject(hMemDc,hBitmap);
					 for (int i=0;i<size.cx;i++)
						 for(int j=0;j<size.cy;j++)
						 {
							 BitBlt(hMemDc,size.cx-i,size.cy-j,1,1,hdckaynak,i,j,SRCCOPY);
						 }
					 SelectObject(hMemDc,hOld);
					 DeleteDC (hMemDc);
					 ReleaseDC(NULL,hdckaynak);
					 pictureBox2->Image=Image::FromHbitmap(hBitmap);
					 DeleteObject(hBitmap);
				 }
				 
PictureBox1 içerisindeki resmi tepetaklak yapıp PictureBox2 içerisine gönderiyor. BitBlt sonundaki komutu değiştirerek değişik durumlar elde edebilirsiniz. :elsalla:

Tabiki kodda oldukça hızlı çalışıyor ve CPU farkına bile varmıyor.
Cevapla