int main(int argc, char *argv[]) { dc1394camera_t *pCamera, **pCameras=NULL; int iNumCameras; dc1394featureset_t xFeatures; int i; int err=dc1394_find_cameras(&pCameras, &iNumCameras); JPEGData *pData; ExifData * pEd; if (err!=DC1394_SUCCESS) { fprintf( stderr, "Unable to look for cameras\n\n" "Please check \n" " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n" " - if you have read/write access to /dev/raw1394\n\n"); exit(1); } if (iNumCameras<1) { fprintf(stderr, "no cameras found :(\n"); exit(1); } pCamera=pCameras[0]; for (i=1;i<iNumCameras;i++) dc1394_free_camera(pCameras[i]); free(pCameras); if(dc1394_get_camera_feature_set(pCamera, &xFeatures)!=DC1394_SUCCESS) fprintf(stdout, "unable to get feature set\n"); else printf("camera's feature set retrieved\n"); createEXIF(&xFeatures, &pEd); pData = jpeg_data_new_from_file (FILENAME); if (!pData) { printf ("Could not load '%s'!\n", FILENAME); return (-1); } printf("Saving EXIF data to jpeg file\n"); jpeg_data_set_exif_data (pData, pEd); printf("Set the data\n"); jpeg_data_save_file(pData, "foobar2.jpg"); return 0; }
void ChatImageItem::downloadOrViewImage() { if (retryButton) { message.status = FMessage::Uploading; retryButton = false; setButton(); emit mediaUpload(message); } else if (message.media_wa_type == FMessage::Location) { QString url = (message.media_url.isEmpty()) ? URL_LOCATION_SHARING + QString::number(message.latitude) + "," + QString::number(message.longitude) + "+(" + message.notify_name.replace("<","<").replace(">",">") + ")" : message.media_url; QDesktopServices::openUrl(QUrl(url)); } else if (!message.local_file_uri.isEmpty()) { QString uri = "file://" + message.local_file_uri; QDBusConnection dbus = QDBusConnection::sessionBus(); switch (message.media_wa_type) { case FMessage::Audio: if (message.live) { AudioPlayer *player = new AudioPlayer(this); connect(player,SIGNAL(progress(int)),this,SLOT(updateTime(int))); connect(player,SIGNAL(finished()),this,SLOT(finishedAudioPlay())); ui->viewImageButton->setEnabled(false); player->play(uri); // We need to notificate the sender that we played the audio emit voiceNotePlayed(message); break; } case FMessage::Video: { DBusNokiaMediaPlayerIf *mediaPlayerBus = new DBusNokiaMediaPlayerIf(NOKIA_MEDIAPLAYER_DBUS_NAME, NOKIA_MEDIAPLAYER_DBUS_PATH, dbus,this); mediaPlayerBus->mime_open(uri); } break; case FMessage::Image: { // The following is to avoid an Image Viewer bug where files without // EXIF data can't be opened. QImageReader image(message.local_file_uri); if (image.format() == "jpeg") { ExifData *ed = exif_data_new_from_file(message.local_file_uri.toUtf8().constData()); if (!ed) { ed = exif_data_new(); if (ed) { Utilities::logData("Creating default Exif data."); ExifEntry *entry = exif_entry_new(); exif_content_add_entry(ed->ifd[EXIF_IFD_0], entry); exif_entry_initialize(entry, EXIF_TAG_IMAGE_DESCRIPTION); entry->data = (unsigned char *) YAPPARI_APPLICATION_NAME; JPEGData *jpeg = jpeg_data_new_from_file(message.local_file_uri.toUtf8().constData()); jpeg_data_set_exif_data(jpeg, ed); jpeg_data_save_file(jpeg, message.local_file_uri.toUtf8().constData()); jpeg_data_unref(jpeg); } } if (ed) exif_data_unref(ed); } DBusNokiaImageViewerIf *imageViewerBus = new DBusNokiaImageViewerIf(NOKIA_IMAGEVIEWER_DBUS_NAME, NOKIA_IMAGEVIEWER_DBUS_PATH, dbus,this); imageViewerBus->mime_open(uri); } break; }