Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Custom Shape QR Code #189

Open
ashishCodixel opened this issue Sep 2, 2022 · 3 comments
Open

Export Custom Shape QR Code #189

ashishCodixel opened this issue Sep 2, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@ashishCodixel
Copy link

ashishCodixel commented Sep 2, 2022

I have generated custom eyeModule shape and eyeModule dot shape,
then after when i am trying to download that generated QR code using image data with size of 1024 ,
downloaded image from image bytes is ruined. i am not getting perfect readable QRcode but in the flutter ui with help of widget qr code is perfect readable. Below are the code for generate and export.

Code for UI

final appearance = QrAppearance(
          gapSize: 1,
          moduleStyle: QrDataModuleStyle(
            colors: QrColors.random([
              const Color(0xFF000000),
              // const Color(0xFF008253),
              // const Color(0xFF2AB689),
              // const Color(0xFF7BD4AB),
            ]),
            shape: QrDataModuleShape.beakSquare,

          ),
          markerStyle: const QrMarkerStyle(
            color: Color(0xFF000000),
            shape: QrMarkerShape.pencilSketch,
            gap: 2,
          ),
          markerDotStyle: const QrMarkerDotStyle(
            color: Color(0xFF000000),
            shape: QrMarkerDotShape.pencilSketch,
          ),
          embeddedImageStyle: const QrEmbeddedImageStyle(
            size: Size.square(72),
            drawOverModules: false,
          ),
        );

Code for export

_painter = QrPainter(
          data: codeMessage,
          version: QrVersions.auto,
          errorCorrectionLevel: QrErrorCorrectLevel.M,
          embeddedImage: snapshot.data,
          appearance: appearance,
        );
      imageData = await _painter.toImageData(1024,format: ImageByteFormat.png);

Code for Custom Shape
added custome shape in qr_painter.dart file

else if(dotStyle.shape == QrMarkerDotShape.pencilSketch){
        final mPointLeft = (markerOffset.dx - 3) + metrics.pixelSize + strokeAdjust;
        final mPointTop = (markerOffset.dy - 3) + metrics.pixelSize + strokeAdjust;
        Size mSize = Size(radius - 30, radius - 30);

        Path path_1 = Path();
        path_1.moveTo(mSize.width*0.05580000 + mPointLeft,mSize.height*0.9972000 + mPointTop);
        path_1.lineTo(mSize.width*0.005250000 + mPointLeft,mSize.height*0.9999500 + mPointTop);
        path_1.lineTo(mSize.width*0.005000000 + mPointLeft,mSize.height*0.9999500 + mPointTop);
        path_1.lineTo(mSize.width*0.004650000 + mPointLeft,mSize.height + mPointTop);
        path_1.lineTo(0 + mPointLeft,mSize.height*0.9619000 + mPointTop);
        path_1.lineTo(mSize.width*0.01085000 + mPointLeft,mSize.height*0.9238500 + mPointTop);
        path_1.lineTo(mSize.width*0.001550000 + mPointLeft,mSize.height*0.8857500 + mPointTop);
        path_1.lineTo(mSize.width*0.001550000 + mPointLeft,mSize.height*0.8477000 + mPointTop);
        path_1.lineTo(0 + mPointLeft,mSize.height*0.8096000 + mPointTop);
        path_1.lineTo(mSize.width*0.006200000 + mPointLeft,mSize.height*0.7715000 + mPointTop);
        path_1.lineTo(0 + mPointLeft,mSize.height*0.7335000 + mPointTop);
        path_1.lineTo(mSize.width*0.001550000 + mPointLeft,mSize.height*0.6954000 + mPointTop);
        path_1.lineTo(mSize.width*0.007750000 + mPointLeft,mSize.height*0.6573500 + mPointTop);
        path_1.lineTo(mSize.width*0.004650000 + mPointLeft,mSize.height*0.6192500 + mPointTop);
        path_1.lineTo(mSize.width*0.003100000 + mPointLeft,mSize.height*0.5811500 + mPointTop);
        path_1.lineTo(mSize.width*0.01705000 + mPointLeft,mSize.height*0.5431000 + mPointTop);
        path_1.lineTo(mSize.width*0.007750000 + mPointLeft,mSize.height*0.5050000 + mPointTop);
        path_1.lineTo(mSize.width*0.003100000 + mPointLeft,mSize.height*0.4669000 + mPointTop);
        path_1.lineTo(mSize.width*0.006200000 + mPointLeft,mSize.height*0.4288500 + mPointTop);
        path_1.lineTo(mSize.width*0.003100000 + mPointLeft,mSize.height*0.3907500 + mPointTop);
        path_1.lineTo(mSize.width*0.01085000 + mPointLeft,mSize.height*0.3541000 + mPointTop);
        path_1.lineTo(mSize.width*0.009300000 + mPointLeft,mSize.height*0.3160000 + mPointTop);
        path_1.lineTo(mSize.width*0.01550000 + mPointLeft,mSize.height*0.2398500 + mPointTop);
        path_1.lineTo(mSize.width*0.001550000 + mPointLeft,mSize.height*0.2017500 + mPointTop);
        path_1.lineTo(mSize.width*0.009300000 + mPointLeft,mSize.height*0.1637000 + mPointTop);
        path_1.lineTo(mSize.width*0.003100000 + mPointLeft,mSize.height*0.1256000 + mPointTop);
        path_1.lineTo(mSize.width*0.01085000 + mPointLeft,mSize.height*0.08190000 + mPointTop);
        path_1.lineTo(mSize.width*0.007750000 + mPointLeft,mSize.height*0.05370000 + mPointTop);
        path_1.lineTo(mSize.width*0.004800000 + mPointLeft,mSize.height*0.03370000 + mPointTop);
        path_1.lineTo(0 + mPointLeft,mSize.height*0.003050000 + mPointTop);
        path_1.lineTo(mSize.width*0.03830000 + mPointLeft,mSize.height*0.004550000 + mPointTop);
        path_1.lineTo(mSize.width*0.07665000 + mPointLeft,mSize.height*0.01075000 + mPointTop);
        path_1.lineTo(mSize.width*0.1131500 + mPointLeft,mSize.height*0.01075000 + mPointTop);
        path_1.lineTo(mSize.width*0.1518500 + mPointLeft,mSize.height*0.007650000 + mPointTop);
        path_1.lineTo(mSize.width*0.1902000 + mPointLeft,mSize.height*0.007650000 + mPointTop);
        path_1.lineTo(mSize.width*0.2285000 + mPointLeft,mSize.height*0.01700000 + mPointTop);
        path_1.lineTo(mSize.width*0.2668500 + mPointLeft,mSize.height*0.006200000 + mPointTop);
        path_1.lineTo(mSize.width*0.3051500 + mPointLeft,mSize.height*0.01085000 + mPointTop);
        path_1.lineTo(mSize.width*0.3434500 + mPointLeft,mSize.height*0.001600000 + mPointTop);
        path_1.lineTo(mSize.width*0.3818000 + mPointLeft,mSize.height*0.003100000 + mPointTop);
        path_1.lineTo(mSize.width*0.4201000 + mPointLeft,mSize.height*0.01390000 + mPointTop);
        path_1.lineTo(mSize.width*0.4584500 + mPointLeft,mSize.height*0.01700000 + mPointTop);
        path_1.lineTo(mSize.width*0.4953500 + mPointLeft,mSize.height*0.01550000 + mPointTop);
        path_1.lineTo(mSize.width*0.5720000 + mPointLeft,mSize.height*0.006100000 + mPointTop);
        path_1.lineTo(mSize.width*0.6103000 + mPointLeft,mSize.height*0.004600000 + mPointTop);
        path_1.lineTo(mSize.width*0.6486000 + mPointLeft,mSize.height*-0.00005000000 + mPointTop);
        path_1.lineTo(mSize.width*0.6869500 + mPointLeft,mSize.height*0.006100000 + mPointTop);
        path_1.lineTo(mSize.width*0.7252500 + mPointLeft,mSize.height*0.006100000 + mPointTop);
        path_1.lineTo(mSize.width*0.7636000 + mPointLeft,mSize.height*0.01535000 + mPointTop);
        path_1.lineTo(mSize.width*0.8019000 + mPointLeft,mSize.height*0.003050000 + mPointTop);
        path_1.lineTo(mSize.width*0.8402500 + mPointLeft,mSize.height*0.009200000 + mPointTop);
        path_1.lineTo(mSize.width*0.8785500 + mPointLeft,mSize.height*0.001500000 + mPointTop);
        path_1.lineTo(mSize.width*0.9168500 + mPointLeft,mSize.height*0.001500000 + mPointTop);
        path_1.lineTo(mSize.width*0.9549500 + mPointLeft,mSize.height*0.01070000 + mPointTop);
        path_1.lineTo(mSize.width*0.9932500 + mPointLeft,mSize.height*0.009850000 + mPointTop);
        path_1.lineTo(mSize.width*0.9931000 + mPointLeft,mSize.height*0.01380000 + mPointTop);
        path_1.lineTo(mSize.width*0.9935000 + mPointLeft,mSize.height*0.01380000 + mPointTop);
        path_1.lineTo(mSize.width*0.9929000 + mPointLeft,mSize.height*0.01800000 + mPointTop);
        path_1.lineTo(mSize.width*0.9917000 + mPointLeft,mSize.height*0.04795000 + mPointTop);
        path_1.lineTo(mSize.width*0.9855000 + mPointLeft,mSize.height*0.08600000 + mPointTop);
        path_1.lineTo(mSize.width*0.9855000 + mPointLeft,mSize.height*0.1222500 + mPointTop);
        path_1.lineTo(mSize.width*0.9886000 + mPointLeft,mSize.height*0.1607500 + mPointTop);
        path_1.lineTo(mSize.width*0.9886000 + mPointLeft,mSize.height*0.1988500 + mPointTop);
        path_1.lineTo(mSize.width*0.9793000 + mPointLeft,mSize.height*0.2369000 + mPointTop);
        path_1.lineTo(mSize.width*0.9901500 + mPointLeft,mSize.height*0.2750000 + mPointTop);
        path_1.lineTo(mSize.width*0.9855000 + mPointLeft,mSize.height*0.3131000 + mPointTop);
        path_1.lineTo(mSize.width*0.9948000 + mPointLeft,mSize.height*0.3511500 + mPointTop);
        path_1.lineTo(mSize.width*0.9932500 + mPointLeft,mSize.height*0.3892500 + mPointTop);
        path_1.lineTo(mSize.width*0.9824000 + mPointLeft,mSize.height*0.4273500 + mPointTop);
        path_1.lineTo(mSize.width*0.9793000 + mPointLeft,mSize.height*0.4654000 + mPointTop);
        path_1.lineTo(mSize.width*0.9808000 + mPointLeft,mSize.height*0.5021000 + mPointTop);
        path_1.lineTo(mSize.width*0.9901500 + mPointLeft,mSize.height*0.5782500 + mPointTop);
        path_1.lineTo(mSize.width*0.9917000 + mPointLeft,mSize.height*0.6163000 + mPointTop);
        path_1.lineTo(mSize.width*0.9963500 + mPointLeft,mSize.height*0.6544000 + mPointTop);
        path_1.lineTo(mSize.width*0.9901500 + mPointLeft,mSize.height*0.6925000 + mPointTop);
        path_1.lineTo(mSize.width*0.9901500 + mPointLeft,mSize.height*0.7305500 + mPointTop);
        path_1.lineTo(mSize.width*0.9808500 + mPointLeft,mSize.height*0.7686500 + mPointTop);
        path_1.lineTo(mSize.width*0.9932500 + mPointLeft,mSize.height*0.8067000 + mPointTop);
        path_1.lineTo(mSize.width*0.9870500 + mPointLeft,mSize.height*0.8448000 + mPointTop);
        path_1.lineTo(mSize.width*0.9948000 + mPointLeft,mSize.height*0.8829000 + mPointTop);
        path_1.lineTo(mSize.width*0.9948000 + mPointLeft,mSize.height*0.9209500 + mPointTop);
        path_1.lineTo(mSize.width*0.9888500 + mPointLeft,mSize.height*0.9452500 + mPointTop);
        path_1.lineTo(mSize.width + mPointLeft,mSize.height*0.9885000 + mPointTop);
        path_1.lineTo(mSize.width*0.9580000 + mPointLeft,mSize.height*0.9900500 + mPointTop);
        path_1.lineTo(mSize.width*0.9361500 + mPointLeft,mSize.height*0.9839000 + mPointTop);
        path_1.lineTo(mSize.width*0.9197000 + mPointLeft,mSize.height*0.9792500 + mPointTop);
        path_1.lineTo(mSize.width*0.8814000 + mPointLeft,mSize.height*0.9885000 + mPointTop);
        path_1.lineTo(mSize.width*0.8430500 + mPointLeft,mSize.height*0.9885000 + mPointTop);
        path_1.lineTo(mSize.width*0.8047500 + mPointLeft,mSize.height*0.9900500 + mPointTop);
        path_1.lineTo(mSize.width*0.7664500 + mPointLeft,mSize.height*0.9839000 + mPointTop);
        path_1.lineTo(mSize.width*0.7281000 + mPointLeft,mSize.height*0.9900500 + mPointTop);
        path_1.lineTo(mSize.width*0.6898000 + mPointLeft,mSize.height*0.9885500 + mPointTop);
        path_1.lineTo(mSize.width*0.6514500 + mPointLeft,mSize.height*0.9823500 + mPointTop);
        path_1.lineTo(mSize.width*0.6131500 + mPointLeft,mSize.height*0.9854000 + mPointTop);
        path_1.lineTo(mSize.width*0.5748000 + mPointLeft,mSize.height*0.9870000 + mPointTop);
        path_1.lineTo(mSize.width*0.5365000 + mPointLeft,mSize.height*0.9731000 + mPointTop);
        path_1.lineTo(mSize.width*0.4981500 + mPointLeft,mSize.height*0.9823500 + mPointTop);
        path_1.lineTo(mSize.width*0.4598500 + mPointLeft,mSize.height*0.9870000 + mPointTop);
        path_1.lineTo(mSize.width*0.4215500 + mPointLeft,mSize.height*0.9839000 + mPointTop);
        path_1.lineTo(mSize.width*0.3832000 + mPointLeft,mSize.height*0.9870000 + mPointTop);
        path_1.lineTo(mSize.width*0.3463000 + mPointLeft,mSize.height*0.9792500 + mPointTop);
        path_1.lineTo(mSize.width*0.3080000 + mPointLeft,mSize.height*0.9808000 + mPointTop);
        path_1.lineTo(mSize.width*0.2313500 + mPointLeft,mSize.height*0.9746500 + mPointTop);
        path_1.lineTo(mSize.width*0.1930000 + mPointLeft,mSize.height*0.9885000 + mPointTop);
        path_1.lineTo(mSize.width*0.1547000 + mPointLeft,mSize.height*0.9808000 + mPointTop);
        path_1.lineTo(mSize.width*0.1164000 + mPointLeft,mSize.height*0.9869500 + mPointTop);
        path_1.lineTo(mSize.width*0.07240000 + mPointLeft,mSize.height*0.9792500 + mPointTop);
        path_1.lineTo(mSize.width*0.05605000 + mPointLeft,mSize.height*0.9938500 + mPointTop);
        path_1.lineTo(mSize.width*0.05580000 + mPointLeft,mSize.height*0.9971500 + mPointTop);
        path_1.close();

        Paint paint_1_fill = Paint()..style=PaintingStyle.fill;
        paint_1_fill.color = appearance.markerDotStyle!.color.withOpacity(1.0);
        canvas.drawPath(path_1,paint_1_fill);
      }

How show In UI
widget_ui_image

Exported Image
downlaoded_image_1024x1024 copy

@ashishCodixel ashishCodixel added the bug Something isn't working label Sep 2, 2022
@ashishCodixel ashishCodixel changed the title Custom Shape Generate and download qr Export Custom Shape QR Code Sep 2, 2022
@ashishCodixel
Copy link
Author

@lukef hello please give me an answer as soon as possible.

@kopianan
Copy link

kopianan commented Nov 2, 2022

please merge this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants