c# - Where does this quality loss on Images come from? -


Is linked to a database through SQL clinic which I Vinform application

I save images (always * .png) table that looks like this:.

  CREATE TABLE [dbo] [Images] ([ID] INT identity (1, 1) No NULL, [build] image, zero primary key cluster ([ID] ASC));  

Before I can store a picture, it has to be changed to byte [] and this is how I do it:

< pre> public static byte [] ImageToByteArray (System.Drawing.Image imageIn) (MemoryStream ms = using {new MemoryStream ()) {imageIn.Save (MS, System.Drawing.Imaging.ImageFormat.Png); Return to MS. ToArray (); }}

After this, if I want to load the same picture in my picture in a picture box, then I will replace it with this method:

  public static image Baitarereoijej (byte [] Baitarein in) ((Memoristrym ms = new Memoristrym (Baitarein in)) (image Mapper = image. Fomstrym (MS); return back Ayej;}}  

It actually works, only one problem occurs when I see I try to display an image from the database in the box.

So when I get this image in the database:

And later I try to show it this suddenly:

Enter image details here

I already use PictureBox (Normal, Stretchimage, AutoSize, CenterImage, Zoom) for all the possible SizeMode settings and tried it now Also looks like this.

Also how I load images from the database to PictureBox:

  public static ImageList GetRezeptImages (integer rezeptId) using { (CookBookDataContext ctx = new CookBookDataContext (ResourceFile:  

first of all I retrieve all related to a set through the ID images .DBConnection)) {IEnumerable & lt; RezeptBilder & gt; Bilder = b to ctx.RezeptBilders where b.FKRezept == rezeptIdB choose; Imagist Imagist = new imagelist (); Forchha (Ripplebuster B in Builder) {imageList.Images.Add (Helper.BiateArereTimeez (B. Build.ToRray ()); } Back to the image list; }}

In addition to this, I have a Datagrid visit where the ID is stored in the first column. When I set up relates want to get any picture I do it like this:

  private void dgvRezeptListe_CellClick (object sender, DataGridViewCellEventArgs e) {pbRezeptBild.Image = DBManager.GetRezeptImages (Int32 .Parse (dgvRezeptListe.SelectedRows [0]. Cells [0] .Value.ToString ())) Images [0]. }  

When the image is loaded from a local directory, the image looks ok in the picture box. I also tried to convert the initial picture to binary and back (without loading the database), it still looks fine when it appears in the picture box.

This is strange when viewing the ImageSize, width and height of both the databases in 16 because the original image is completely different dimension.

Any thoughts?

After the

It seems that ImageList changes your pictures to MemoryBmp when you Adding them to the list GetRezeptImages .
I do not know why this happens, but this is the reason for the loss of your quality in the image. As you've also felt, the image is converted into a 16x16 image and then when your PictureBox is changed to the original size in , then it only looks more cheese.

Edit: From the comment of TOW: The Imagist Collection can not control the pictures of different sizes, so it is changing all the images to a normal size. Since there is no set size, it seems that it is a mistake for 16x16.

I recommend that you send GetRezceptImages to a list image & gt; Use it according to a ImageList instead of showing more pictures.

Alternatively, if you always use the GetRezceptImages method in the same way you have shown in your question, you can always use it for a Image object Can return the first image and remove all the lists completely.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -