久久精品精选,精品九九视频,www久久只有这里有精品,亚洲熟女乱色综合一区
    分享

    iOS開發

     Han_Count 2016-07-14
    #pragma mark-> 二維碼生成
    -(void)create{

    UIImage *image=[UIImage imageNamed:@"6824500_006_thumb.jpg"];
    NSString*tempStr;
    if(self.textField.text.length==0){

    tempStr=@"ddddddddd";

    }else{

    tempStr=self.textField.text;

    }
    UIImage*tempImage=[QRCodeGenerator qrImageForString:tempStr imageSize:360 Topimg:image withColor:RandomColor];

    _outImageView.image=tempImage;

    }
    +(UIImage*)qrImageForString:(NSString *)string imageSize:(CGFloat)size Topimg:(UIImage *)topimg withColor:(UIColor*)color{

    if (![string length]) {
    return nil;
    }

    QRcode *code = QRcode_encodeString([string UTF8String], 0, QR_ECLEVEL_L, QR_MODE_8, 1);
    if (!code) {
    return nil;
    }

    // create context
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef ctx = CGBitmapContextCreate(0, size, size, 8, size * 4, colorSpace, kCGImageAlphaPremultipliedLast);

    CGAffineTransform translateTransform = CGAffineTransformMakeTranslation(0, -size);
    CGAffineTransform scaleTransform = CGAffineTransformMakeScale(1, -1);
    CGContextConcatCTM(ctx, CGAffineTransformConcat(translateTransform, scaleTransform));

    // draw QR on this context
    [QRCodeGenerator drawQRCode:code context:ctx size:size withPointType:0 withPositionType:0 withColor:color];

    // get image
    CGImageRef qrCGImage = CGBitmapContextCreateImage(ctx);
    UIImage * qrImage = [UIImage imageWithCGImage:qrCGImage];

    if(topimg)
    {
    UIGraphicsBeginImageContext(qrImage.size);

    //Draw image2
    [qrImage drawInRect:CGRectMake(0, 0, qrImage.size.width, qrImage.size.height)];

    //Draw image1
    float r=qrImage.size.width*35/240;
    [topimg drawInRect:CGRectMake((qrImage.size.width-r)/2, (qrImage.size.height-r)/2 ,r, r)];

    qrImage=UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();
    }

    // some releases
    CGContextRelease(ctx);
    CGImageRelease(qrCGImage);
    CGColorSpaceRelease(colorSpace);
    QRcode_free(code);

    return qrImage;

    }
    + (void)drawQRCode:(QRcode *)code context:(CGContextRef)ctx size:(CGFloat)size withPointType:(QRPointType)pointType withPositionType:(QRPositionType)positionType withColor:(UIColor *)color {
    unsigned char *data = 0;
    int width;
    data = code->data;
    width = code->width;
    float zoom = (double)size / (code->width + 2.0 * qr_margin);
    CGRect rectDraw = CGRectMake(0, 0, zoom, zoom);

    // draw
    const CGFloat *components;
    if (color) {
    components = CGColorGetComponents(color.CGColor);
    }else {
    components = CGColorGetComponents([UIColor blackColor].CGColor);
    }
    CGContextSetRGBFillColor(ctx, components[0], components[1], components[2], 1.0);
    NSLog(@"aad :%f bbd :%f ccd:%f",components[0],components[1],components[2]);

    for(int i = 0; i < width; ++i) {
    for(int j = 0; j < width; ++j) {
    if(*data & 1) {
    rectDraw.origin = CGPointMake((j + qr_margin) * zoom,(i + qr_margin) * zoom);
    if (positionType == QRPositionNormal) {
    switch (pointType) {
    case QRPointRect:
    CGContextAddRect(ctx, rectDraw);
    break;
    case QRPointRound:
    CGContextAddEllipseInRect(ctx, rectDraw);
    break;
    default:
    break;
    }
    }else if(positionType == QRPositionRound) {
    switch (pointType) {
    case QRPointRect:
    CGContextAddRect(ctx, rectDraw);
    break;
    case QRPointRound:
    if ((i>=0 && i<=6 && j>=0 && j<=6) || (i>=0 && i<=6 && j>=width-7-1 && j<=width-1) || (i>=width-7-1 && i<=width-1 && j>=0 && j<=6)) {
    CGContextAddRect(ctx, rectDraw);
    }else {
    CGContextAddEllipseInRect(ctx, rectDraw);
    }
    break;
    default:
    break;
    }
    }
    }
    ++data;
    }
    }
    CGContextFillPath(ctx);
    }

      本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發現有害或侵權內容,請點擊一鍵舉報。
      轉藏 分享 獻花(0

      0條評論

      發表

      請遵守用戶 評論公約

      主站蜘蛛池模板: 制服丝袜美腿一区二区| 亚洲色成人一区二区三区| 亚洲偷自拍国综合| 2021AV在线无码最新| 久久精品国产免费观看三人同眠| 免费在线黄色电影| 日本一区二区三区免费播放视频站 | 国精产品一区二区三区有限公司| 人妻中文字幕亚洲一区| 国产精品久久久久久久网| 成人H视频在线观看| 国产片AV国语在线观看手机版| 美女黄18以下禁止观看| 久青草国产在视频在线观看| 狠狠色丁香婷婷综合潮喷| 亚洲欧美综合人成在线| 97人妻人人做人碰人人爽| 精品国产成人国产在线观看| 亚洲AV无码乱码国产麻豆| 最新国产精品好看的精品| 四虎亚洲精品无码| 中国少妇初尝黑人巨高清| 少妇久久久久久久久久| 啊轻点灬大JI巴太粗太长了欧美 | 国产亚洲精品自在久久蜜TV| 肥臀浪妇太爽了快点再快点| 国产裸体XXXX视频在线播放| 国产午夜精品福利视频| 免费人成在线观看网站| 亚洲区色欧美另类图片| 国产亚洲色视频在线| 国产精品无码久久综合网| 综合色一色综合久久网| 久久亚洲精品11p| 亚洲日韩精品欧美一区二区| 欧美熟妇性XXXX欧美熟人多毛| 真人性囗交视频| 爽爽影院免费观看| 乱人伦无码中文视频在线| 麻豆精品一区二区综合av| 午夜久久久久久禁播电影|