locked
troubles with images RRS feed

  • Question

  • I have some problems to print an image of a form with this code, I see that the image deteriorates in some cases,
    leave some white squares,

    I would like to know how  can avoid that.

       
                              Bitmap bmp = new Bitmap(pnlImagenIzquierda.Width, pnlImagenIzquierda.Height, pnlImagenIzquierda.CreateGraphics());
                                pnlImagenIzquierda.Refresh();
                                picFotoIzquierda.Refresh();
                                picFotoDerecha.Refresh();
                                pnlImagenIzquierda.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
                                bmp.Save(miRuta + cboEmpleados.SelectedValue + ConfigurationManager.AppSettings["extensionExportar"].ToString());
    image with error
    im

    original image


    Wednesday, May 4, 2016 7:06 PM

Answers

  • Hi Palermo_software,

    >>"pnlImagenIzquierda.Refresh();"

    Is it a PictureBox control? PictureBox has a property named SizeMode. The form will do some processing on the image when displayed according this property. If you want to save the source of the PictureBox control as a image, you could use following code.

    pnlImagenIzquierda.Image.Save(path);

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Hi thanks for your answer

    actually what worked for me was to make this change

     Bitmap bmp = new Bitmap(pnlImagenIzquierda.Width, pnlImagenIzquierda.Height, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);

    instead

    pnlImagenIzquierda.CreateGraphics());

    as the last parameter, now all the images look good

    Wednesday, May 11, 2016 7:16 PM

All replies

  • Hi Palermo_software,

    >>"pnlImagenIzquierda.Refresh();"

    Is it a PictureBox control? PictureBox has a property named SizeMode. The form will do some processing on the image when displayed according this property. If you want to save the source of the PictureBox control as a image, you could use following code.

    pnlImagenIzquierda.Image.Save(path);

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Saturday, May 7, 2016 7:16 AM
  • Hi Palermo_software,

    >>"pnlImagenIzquierda.Refresh();"

    Is it a PictureBox control? PictureBox has a property named SizeMode. The form will do some processing on the image when displayed according this property. If you want to save the source of the PictureBox control as a image, you could use following code.

    pnlImagenIzquierda.Image.Save(path);

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Hi thanks for your answer

    actually what worked for me was to make this change

     Bitmap bmp = new Bitmap(pnlImagenIzquierda.Width, pnlImagenIzquierda.Height, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);

    instead

    pnlImagenIzquierda.CreateGraphics());

    as the last parameter, now all the images look good

    Wednesday, May 11, 2016 7:16 PM