From b420a962620f6df5b4abbb2316db7def6f150994 Mon Sep 17 00:00:00 2001 From: Shawn Lawson Date: Mon, 16 Jan 2012 11:51:27 -0500 Subject: [PATCH 1/2] custom filename, custom live draw size --- src/Canon.cpp | 23 +++++++++++++++++++++++ src/Canon.h | 4 ++++ src/CanonTaskDownloadPicture.cpp | 16 +++++++++++++--- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/Canon.cpp b/src/Canon.cpp index 167eaa4..d418983 100644 --- a/src/Canon.cpp +++ b/src/Canon.cpp @@ -14,6 +14,7 @@ Canon::Canon() ,connection(this) ,session_open(false) ,live_view_requested(false) +,file_name("") { queue.setCanon(this); instance_ = this; @@ -112,6 +113,14 @@ ofPixels& Canon::getLivePixels() { string Canon::getDownloadDir() { return ofToDataPath("./",true); } + +void Canon::setFileName(string newFileName){ + file_name = newFileName; +} + +string Canon::getFileName(){ + return file_name; +} void Canon::getProperty(EdsPropertyID propID) { queue.addTask(new CanonTaskGetProperty(propID)); @@ -164,6 +173,20 @@ void Canon::drawLiveView(int x, int y) { live_texture.draw(x,y); } +void Canon::drawLiveViewWithSize(int x, int y, int w, int h) { + if(has_new_live_image) { + if(live_texture.getWidth() != live_pixels.getWidth() + || live_texture.getHeight() != live_pixels.getHeight() + ) + { + live_texture.allocate(live_pixels.getWidth(), live_pixels.getHeight(), GL_RGB8); + } + live_texture.loadData(live_pixels); + has_new_live_image = false; + } + live_texture.draw(x,y,w,h); +} + void Canon::onCanonEvent(CanonEvent& ev) { if(ev.name == "evf_data_changed") { EdsUInt32 length; diff --git a/src/Canon.h b/src/Canon.h index d5621da..2fcdcb1 100644 --- a/src/Canon.h +++ b/src/Canon.h @@ -35,12 +35,15 @@ namespace roxlu { bool isCameraConnected(); void takePicture(); string getDownloadDir(); + void setFileName(string newFileName); + string getFileName(); bool isSessionOpen(); bool isLiveViewActive(); void startLiveView(); void endLiveView(); void drawLiveView(int x = 0, int y = 0); + void drawLiveViewWithSize(int x, int y, int w, int h); ofPixels& getLivePixels(); static Canon& instance(); @@ -132,6 +135,7 @@ namespace roxlu { bool live_view_requested; bool has_new_live_image; bool session_open; + string file_name; ofBuffer live_buffer; ofTexture live_texture; ofPixels live_pixels; diff --git a/src/CanonTaskDownloadPicture.cpp b/src/CanonTaskDownloadPicture.cpp index ac3a259..820b4fa 100644 --- a/src/CanonTaskDownloadPicture.cpp +++ b/src/CanonTaskDownloadPicture.cpp @@ -16,7 +16,12 @@ bool CanonTaskDownloadPicture::execute() { // Created file stream to download image. if(err == EDS_ERR_OK) { - string dest = Canon::instance().getDownloadDir() +dir_item_info.szFileName; + string dest; + if(Canon::instance().getFileName() == "") + dest = Canon::instance().getDownloadDir() +dir_item_info.szFileName; + else + dest = Canon::instance().getDownloadDir() + Canon::instance().getFileName(); + // a err = EdsCreateFileStream(dest.c_str(), kEdsFileCreateDisposition_CreateAlways, kEdsAccess_ReadWrite, &stream); } if(err != EDS_ERR_OK) { @@ -41,8 +46,13 @@ bool CanonTaskDownloadPicture::execute() { // Tell we're ready. if(err == EDS_ERR_OK) { - CanonPictureEvent ev(dir_item_info.szFileName); - Canon::instance().firePictureTakenEvent(ev); + if(Canon::instance().getFileName() == ""){ + CanonPictureEvent ev(dir_item_info.szFileName); + Canon::instance().firePictureTakenEvent(ev); + }else{ + CanonPictureEvent ev(Canon::instance().getFileName()); + Canon::instance().firePictureTakenEvent(ev); + } err = EdsDownloadComplete(dir_item); } From 31b29f0e31c753b197737736864db68a2639653a Mon Sep 17 00:00:00 2001 From: Shawn Lawson Date: Mon, 23 Jan 2012 15:16:31 -0500 Subject: [PATCH 2/2] fixed a comment --- src/CanonTaskDownloadPicture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CanonTaskDownloadPicture.cpp b/src/CanonTaskDownloadPicture.cpp index 820b4fa..922f348 100644 --- a/src/CanonTaskDownloadPicture.cpp +++ b/src/CanonTaskDownloadPicture.cpp @@ -21,7 +21,7 @@ bool CanonTaskDownloadPicture::execute() { dest = Canon::instance().getDownloadDir() +dir_item_info.szFileName; else dest = Canon::instance().getDownloadDir() + Canon::instance().getFileName(); - // a + err = EdsCreateFileStream(dest.c_str(), kEdsFileCreateDisposition_CreateAlways, kEdsAccess_ReadWrite, &stream); } if(err != EDS_ERR_OK) {