This project is read-only.

black border on file created

Aug 22, 2012 at 7:16 PM

I have been using the CreateImageFile function as following:


string texte = "Hello4";

        QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H );
        QrCode qrCode = qrEncoder.Encode(texte);

        const int moduleSizeInPixels = 4;
        Renderer renderer = new Renderer(moduleSizeInPixels );
        renderer.CreateImageFile(qrCode.Matrix, AppDomain.CurrentDomain.BaseDirectory.ToString() + texte +".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

But the file created has a right and bottom black border.  I don't use much code here so it seems a problem of the source (which I didn't look at; I'm no graphic programmer).

Can this be solved? 

Aug 23, 2012 at 7:47 AM

Its already solved. Report by other user few months ago. Download latest source code and try again. 

For more detail please check following discussion page

Aug 23, 2012 at 4:07 PM

I'm not familiar with Graphics stuff at all.  Can you lead me to create a standard image file?

Aug 23, 2012 at 6:28 PM

Ok, I managed this:


string texte = "Hello18hell";

        QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H );
        QrCode qrCode = qrEncoder.Encode(texte);
        Image1.ImageUrl = texte + ".jpg";

        GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(4, QuietZoneModules.Four));
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        renderer.WriteToStream(qrCode.Matrix ,System.Drawing.Imaging.ImageFormat.Jpeg,ms);
        System.IO.File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory.ToString() + texte + ".jpg", ms.ToArray());

Thank you

Aug 23, 2012 at 7:40 PM

I have graphics renderer example at this page.

Is your project WPF based or winform? As WPF's DrawingBrush renderer is better in result and writeablebitmap renderer is faster. Thus if your project is WPF application, then use those two renderers will be ideal, as you don't have to use winform's library. 


Also you don't have to write from memory stream to file, just create file stream and write onto file stream will do. So you don't have to do that extra step. As long as you don't put any text write stream in, it should work fine. Check our demo example in source code. 

Aug 25, 2012 at 12:03 PM

Thanks for you follow up.

Actually, I'm writing to an html in ASP.NET.  I'm at the point of writing the piece of software to create our departments, users, etc. barcodes that we'll print on labels around our shop floor.  Eventually I might need to use the capacity in reports but most report generators can already generate barcodes.

The image created goes inside a button with a text value under it.  The user press that button and a clean "printable" version comes out on a popup.

And yes I modified the code to this:

 System.IO.FileStream fs = new System.IO.FileStream(AppDomain.CurrentDomain.BaseDirectory.ToString() + attributeValue.Text + ".jpg",System.IO.FileMode.OpenOrCreate);
        renderer.WriteToStream(qrCode.Matrix, System.Drawing.Imaging.ImageFormat.Jpeg, fs);

and it works fine.

Thank you for your help.