wqweto / VbQRCodegen

QR Code generator library for VB6/VBA
MIT No Attribution
46 stars 17 forks source link

Using QRCodegenConvertToPicture producing BMP #7

Open AlessandroBori opened 10 months ago

AlessandroBori commented 10 months ago

Thank you for your efforts, this module is vary useful. I have tried to use this function QRCodegenConvertToPicture and SavePicture trying to save a BMP file but StdPicture produce an EMF file. Any ideas? Is it possible to have a function like QRCodegenToFile and having a file output instead?

wqweto commented 10 months ago

There is already a generic QRCodegenResizePicture procedure which can rasterize and resize any StdPicture, incl. vector ones returned by QRCodegenBarcode and QRCodegenConvertToPicture into another (raster) StdPicture. This new StdPicture can then be persisted to a BMP file with built-in SavePicture.

You can use QRCodegenResizePicture to anti-alias the output too by super-sampling 2x or 4x like it's done in the test Form1 at line 34

Clipboard.SetData QRCodegenResizePicture(QRCodegenResizePicture(QRCodegenConvertToPicture(baBarCode, vbBlue, ModuleSize:=lModuleSize, SquareModules:=(Check1.Value = vbChecked)), 2000, 2000), 500, 500)

Just call it twice with proper sizes depending on final raster size desired i.e beginning with 2000x2000 -> 500x500 is 4x super-sampling.

lvvfa commented 1 month ago

Thank you for your code achievement! Perfectly run in VB6, simple and efficient! I have an application that can only run on 64 bit systems,VB6 is a 32-bit system. Could you please release VB The mdQRCodegen.bas file in VB. NET.

wqweto commented 1 month ago

There is a C# variant of the same Project Nayuki's library here.

Migrating this code to VB.Net is outside my abilities. (I would rather try it in C# though.)