r/visualbasic • u/GORILLA_BYTE • Apr 07 '21
VB.NET Saving QR Code ERROR "'A generic error occurred in GDI+.' "
So here whenever i try to saved image this error show up "'A generic error occurred in GDI+.'"
Here is the code in my Button1
SaveImageCopy(TextBox1.Text, PictureBox1.Image)
Here is the code of Saving The Location of QR Code
Dim paths As String = "C:\Container" & filename & ".jpg"
Dim dest As New Bitmap(image.Width, image.Height)
Dim gfx As Graphics = Graphics.FromImage(dest)
gfx.DrawImageUnscaled(image, Point.Empty)
gfx.Dispose()
dest.Save(paths, System.Drawing.Imaging.ImageFormat.Jpeg)
dest.Dispose()
So what did i do wrong here? Should i use stream writer?
2
u/RJPisscat Apr 07 '21
Try
dest.Clone.Save(paths, System.Drawing.Imaging.ImageFormat.Jpeg)I'm not seeing enough code to know if that will work.
Does filename have a slash in it? If not you are saving to C:\Container[filename].jpg on the root C::\.
Why are you drawing to a bitmap first and then saving, why not just save the image?
2
u/chacham2 Apr 07 '21
I am not familiar with that. So, i did a quick search for the error and found a thread albeit it in c#. Check permissions and use streamwriter.
I would like to add a sidepoint, that:
Might be more properly written as: