2012-07-10 106 views
0

UIPrintInteractionController使用要打印的數據。如果要從imageview打印圖像,它會給我一些警告。我想從imageview中使用圖像,而不是從resources.I想知道如何從圖像中獲取數據ImageView的從imageview打印圖像

UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController]; 
NSData * datatobeprinted [NSData dataWithContentsOfFile:imageView.image]; 
if(printController && [UIPrintInteractionController canPrintData:imageView.image]) { 

    printController.delegate = self; 

    UIPrintInfo *printInfo = [UIPrintInfo printInfo]; 
    printInfo.outputType = UIPrintInfoOutputGeneral; 
    printInfo.jobName = [path lastPathComponent]; 
    printInfo.duplex = UIPrintInfoDuplexLongEdge; 
    printController.printInfo = printInfo; 
    printController.showsPageRange = YES; 
    [printController setPrintingItem:datatobeprinted];  
} 
+0

你可以得到它像UIImage * image = imageView.image.But之後,你想用它在哪裏? – Madhumitha 2012-07-10 08:53:26

回答

1

我覺得你像NSData的需要,那麼你可以做如下:

NSData *imageData = UIImageJPEGRepresentation(image, 0.7); // 0.7 is JPG quality 

NSData *imageData = UIImagePNGRepresentation(image); 

取決於您是否想要PNG格式或JPG格式的數據。

+0

非常感謝toooooo – 2012-07-11 07:59:31