0

I have a big problem when I convert my PictureBox to bitmap with labels to save it in my computer, it appears moved and with a really low resolution, I'm a newbie so... I really don't know how to fix it

here is how it looks saved

here is my code to save it:

System.Drawing.Point pbloc = pictureBox1.PointToScreen(pictureBox1.Location);
        Bitmap bm = new Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height);
        Graphics grx = Graphics.FromImage(bm);
        grx.CopyFromScreen(pbloc.X, pbloc.Y, 0, 0, pictureBox1.Size, CopyPixelOperation.SourceCopy);
        grx.Dispose();


        SaveFileDialog sfd = new SaveFileDialog();
        sfd.Filter = "JPG(*.JPG)|*.jpg";
        if (sfd.ShowDialog() == DialogResult.OK)
        {
            bm.Save(sfd.FileName,
        System.Drawing.Imaging.ImageFormat.Jpeg);
        }

I used this to parent the labels with the PictureBox:

public Registro()
    {

        InitializeComponent();


        var pos1 = this.PointToScreen(label1.Location);
        pos1 = pictureBox1.PointToClient(pos1);
        this.label1.Parent = this.pictureBox1;
        label1.Location = pos1;
Fred
  • 3,365
  • 4
  • 36
  • 57
  • Moving: Why didn't youi use DrawToBitmap? - Resolution: You will always only get the screen resolution. – TaW Feb 29 '20 at 08:16
  • Awesome!, Thanks!, DrawToBitmap worked, but, there is any way to save it in original resolution? (it was +3000px), or just in a better one?, i need it for a Letter Paper Size, to print – Joaquín Jerez Araujo Feb 29 '20 at 09:58
  • because my laptop resolution i can't do a bigger image – Joaquín Jerez Araujo Feb 29 '20 at 10:06
  • The by far best results will be drawing the image and the texts into a bitmap of the size and dpi you choose. Use DrawImage and DrawString. – TaW Feb 29 '20 at 10:29

0 Answers0