Skip to content

High Resolution Image #13

@Seachaos

Description

@Seachaos

Hi:
I Think this can make high resolution QR Image
( Make a bigger Matrix)

////////////////////////////////////////////////////////////////////////////////////////////////////

  • (UIImage *)imageForMatrix:(QRMatrix *)matrix {
    int width = matrix.width;
    int height = matrix.height;

    int bl = 8; // this is make more big matrix
    QRMatrix _newMatrix = [[QRMatrix alloc] initWithWidth:width_bl height:height*bl];
    for(int y = 0; y < height; y++) {
    for(int x = 0; x < width; x++) {
    int
    blx = x * bl,
    bly = y * bl;
    for(int blax = 0; blax<bl ; blax++){
    for(int blay = 0; blay<bl ;blay++){
    [newMatrix setX:blx+blax y:bly+blay value:[matrix getX:x y:y]];
    }
    }
    }
    }

    matrix = newMatrix;
    width = matrix.width;
    height = matrix.height;

    unsigned char *bytes = (unsigned char *)malloc(width * height * 4);
    for(int y = 0; y < height; y++) {
    for(int x = 0; x < width; x++) {
    BOOL bit = [matrix getX:x y:y];
    unsigned char intensity = bit ? 0 : 255;
    for(int i = 0; i < 3; i++) {
    bytes[y * width * 4 + x * 4 + i] = intensity;
    }
    bytes[y * width * 4 + x * 4 + 3] = 255;
    }
    }

    //int width = 32;
    //int height = 32;
    //unsigned char *bytes = (unsigned char *)malloc(width * height);
    //memset(bytes, 255, width * height * 4);

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef c = CGBitmapContextCreate(bytes, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast);
    CFRelease(colorSpace);
    CGImageRef image = CGBitmapContextCreateImage(c);
    CFRelease(c);
    UIImage *image2 = [UIImage imageWithCGImage:image];
    CFRelease(image);
    return image2;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions