muratboy31 Posted October 12, 2015 Share Posted October 12, 2015 Merhaba arkadaşlar, veritabınında bulunan resimleri imagelist e atarken out of memory hatası alıyorum, acaba nasıl bir yol izlemem lazım ? Yüzlerce foto var hepsi imagelistbox ta item ikonu olarak kullanılacak... Teşekkürler Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 12, 2015 Share Posted October 12, 2015 ben şu kodla yaptığımda sorun vermedi: const string klasor = @"D:\img"; DirectoryInfo dir = new DirectoryInfo(klasor); foreach (var item in dir.GetFiles()) { imageList1.Images.Add(Image.FromFile(item.FullName)); } MessageBox.Show("ekleme bitti!"); eklediğim resimler şunlar (32x32 boyutunda): Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 12, 2015 Editor Share Posted October 12, 2015 db ye gömdüğün resimlerin boyutları nedir. BLOB alanlarda o hata çokoluyor genelde. Birde stream ederek eklerken kullandıgınız kodları paylaşırsanız yardımcı olabiliriz. var imgArray = datareader["img"] as byte[]; MemoryStream ms = new MemoryStream(imgArray ); ms.Position = 0; Image returnImage = Image.FromStream(ms); Bu şekilde normalde veritabanıdan geleni aktarabilirsiniz. Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 12, 2015 Share Posted October 12, 2015 resimler veritabanında mıymış ya? bu aralar okuduğumu hiç anlamıyorum valla :mellow: Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 12, 2015 Editor Share Posted October 12, 2015 resimler veritabanında mıymış ya? bu aralar okuduğumu hiç anlamıyorum valla :mellow: Yoğun çalışmaktandır :D Playstation dan uzak dur biraz :D Quote Link to comment Share on other sites More sharing options...
KintaRo Posted October 12, 2015 Share Posted October 12, 2015 son bir oyun kaldı onu da bir bitireyim de ara vereceğim :D Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted October 13, 2015 Author Share Posted October 13, 2015 Merhaba, bu şekilde yapıyorum ; rPhoto = (byte[])rdr.GetValue(11); string strfn = Convert.ToString(rEmployeeID); if (!File.Exists(strfn)) { FileStream fs = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write); fs.Write(rPhoto, 0, rPhoto.Length); fs.Flush(); fs.Close(); } photoList.Images.Add(Image.FromFile(strfn)); Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 13, 2015 Editor Share Posted October 13, 2015 ImageFrom File demişsiniz. Tekrardan file a yazıp memory i boşa tüketmeyin. byte[] haindeyken memory ile yukarıda verdigim örnek gibi direk image e eklersiniz. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted October 13, 2015 Author Share Posted October 13, 2015 aslında yapmak istediğim, ilk açılışta bilgisayara indirmek, eğer o resim var ise tekrardan boşuna indirmesin, bilgisayardakini imagelist e atsın... Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted October 13, 2015 Editor Share Posted October 13, 2015 O zaman mantıklı evet. Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted October 13, 2015 Author Share Posted October 13, 2015 (edited) direk db den sorunsuz çalışıyor, ancak nedense memory hatası veriyor folder dan yapınca, herseferinde aynı resimleri tekrar tekrar indirmek networküde veri tabanınıda yorar gibi ! Edited October 13, 2015 by muratboy31 Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted October 13, 2015 Author Share Posted October 13, 2015 Hallettim, önce eğer klasörde yoksa indiriyorum, sonra image list e atıyorum key ile beraber ve sonra key ile ID yi eşleştiriyorum. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.