forked from netshade/Cocoa-Touch-Barcodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIImage-NKDBarcode.m
41 lines (36 loc) · 1.58 KB
/
UIImage-NKDBarcode.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// -----------------------------------------------------------------------------------
// NSImage-NKDBarcode.m
// -----------------------------------------------------------------------------------
// Created by Jeff LaMarche on Wed May 01 2002.
// Copyright (c) 2002 Naked Software. All rights reserved.
// -----------------------------------------------------------------------------------
// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
// -----------------------------------------------------------------------------------
// You may use and redistribute this source code without limitation
// -----------------------------------------------------------------------------------
#import "UIImage-NKDBarcode.h"
@implementation UIImage(NKDBarcode)
+(UIImage *)imageFromBarcode:(NKDBarcode *)barcode
{
NKDBarcodeOffscreenView * view = [[NKDBarcodeOffscreenView alloc] initWithBarcode:barcode];
CGRect rect = [view bounds];
UIImage * image = [view imageInsideRect:rect];
[view release];
return image;
}
+(NSData *)pdfFromBarcode:(NKDBarcode *)barcode {
NKDBarcodeOffscreenView * view = [[NKDBarcodeOffscreenView alloc] initWithBarcode:barcode];
CGRect rect = [view bounds];
NSData * pdf = [view pdfInsideRect:rect];
[view release];
return pdf;
}
+(UIImage *)imageFromBarcode:(NKDBarcode *)barcode inRect:(CGRect) rect
{
NKDBarcodeOffscreenView * view = [[NKDBarcodeOffscreenView alloc] initWithBarcode:barcode];
[view setFrame:rect];
UIImage * image = [view imageInsideRect:rect];
[view release];
return image;
}
@end