2015-01-27 15 views
1

사용자가 프로필 사진을 찍어 저장할 수있는 앱이 있습니다. 내보기에 URL에서 이미지를로드하는 github에서 https://github.com/RileyGB/BlackBerry10-Samples/tree/master/WebImageViewSample 샘플을 사용하고 있으며 잘 작동합니다. 문제는 내가 프로필 그림을 ios에서 저장하고 블랙 베리에서 프로필 사진을 보았을 때 왼쪽으로 90도 회전 한 것처럼 보입니다. 하지만 같은 url은 ios와 android에서 잘로드됩니다. 아래는 iOS에서 가져온 견본 이미지의 링크입니다.이 이미지는 ios와 android를 올바르게로드하지만 블랙 베리에서 왼쪽으로 90도 이동합니다. 그것은 검은 딸기 또는 안드로이드에서 가지고 간 다른 심상을 위해 잘 작동한다. 이 문제를 해결할 수있는 방법이 있습니까? 어떤 도움을 QML에서로드의 샘플 코드이 이미지를 아래 블랙 베리 폭포에서 이미지 회전 문제

http://oi57.tinypic.com/2hzj2c4.jpg

입니다 감사합니다

Page { 
    Container { 
     layout: DockLayout { 
     } 
     WebImageView { 
      id: webViewImage 
      url: "http://oi57.tinypic.com/2hzj2c4.jpg" 
      horizontalAlignment: HorizontalAlignment.Center 
      verticalAlignment: VerticalAlignment.Center 
      visible: (webViewImage.loading == 1.0) 
     } 
     ProgressIndicator { 
      value: webViewImage.loading 
      verticalAlignment: VerticalAlignment.Center 
      horizontalAlignment: HorizontalAlignment.Center 
      visible: (webViewImage.loading < 1.0) 
     } 
    } 

    actions: [ 
     ActionItem { 
      title: "Clear Cache" 
      ActionBar.placement: ActionBarPlacement.OnBar 
      onTriggered: { 
       webViewImage.clearCache(); 
       webViewImage.url = "http://oi57.tinypic.com/2hzj2c4.jpg"; 
      } 
     } 
    ] 
} 
+0

브라우저 웹 사이트에서 이미지를 열면 이미지도 회전합니다 (그러나 이미지 자체를 보면 괜찮습니다). iOS 및 Android 앱을 직접 만들었습니까? –

+0

[EXIF] (http://webmasters.stackexchange.com/questions/16684/ipad-and-iphone-browser-rotating-images-on-site) 문제를 확인하십시오. I –

+0

아니요, 다른 누군가가 iOS 및 Android에서 앱을 만들었습니다. 블랙 베리로 해보았습니다. 하지만 iOS 나 안드로이드에서이 그림을로드하려고하면 회전없이 올바른 모습을 보여줍니다. 블랙 베리에서 어떻게 수정합니까? 그것은 안드로이드에서 작동하는 것 같습니다 그래서 나는 검은 딸기에 대한 수정도있을 것 같아요 – Gamerlegend

답변

0

나는 webimageview에 추가 기능을 EXIF ​​라이브러리를 추가하고 추가하여이 문제를 해결할 수 있었다 클래스

QByteArray WebImageView::getRotateImage(QByteArray imageFile) 
{ 
    //Load the image using QImage. 
    // A transform will be used to rotate the image according to device and exif orientation. 
     QTransform transform; 
    QImage image; 
    image.loadFromData((unsigned char*)imageFile.data(),imageFile.length(),"JPG"); 

    ExifData *exifData = 0; 
    ExifEntry *exifEntry = 0; 
    int exifOrientation = 1; 

    // Since the image will loose its exif data when its opened in a QImage 
    // it has to be manually rotated according to the exif orientation. 
    exifData = exif_data_new_from_data((unsigned char*)imageFile.data(),(unsigned int)imageFile.size()); 

    // Locate the orientation exif information. 
    if (exifData != NULL) { 

     for (int i = 0; i < EXIF_IFD_COUNT; i++) { 
      exifEntry = exif_content_get_entry(exifData->ifd[i], EXIF_TAG_ORIENTATION); 
      // If the entry corresponds to the orientation it will be a non zero pointer. 
      if (exifEntry) { 
       exifOrientation = exif_get_short(exifEntry->data, exif_data_get_byte_order(exifData)); 
       break; 
      } 
     } 
    } 
    // It's a bit tricky to get the correct orientation of the image. A combination of 
    // the way the the device is oriented and what the actual exif data says has to be used 
    // in order to rotate it in the correct way. 
    switch(exifOrientation) { 
     case 1: 
      // 0 degree rotation 
      return imageFile; 
      break; 
     case 3: 
      // 180 degree rotation 
      transform.rotate(180); 
      break; 
     case 6: 
      // 90 degree rotation 
      transform.rotate(90); 
      break; 
     case 8: 
      // 270 degree rotation 
      transform.rotate(270); 
      break; 
     default: 
      // Other orientations are mirrored orientations, do nothing. 
      break; 
    } 

    // Perform the rotation of the image before its saved. 
    image = image.transformed(transform); 

    QImage img =image; 
    QByteArray arr; 
    QBuffer buf(&arr); 
    buf.open(QIODevice::WriteOnly); 
    img.save(&buf, "PNG"); 
    buf.close(); 
    return arr; 

}