8000 custom live draw, custom file name by shawnlawson · Pull Request #1 · diederickh/ofxCanon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

custom live draw, custom file name #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: simple
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Canon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Canon::Canon()
,connection(this)
,session_open(false)
,live_view_requested(false)
,file_name("")
{
queue.setCanon(this);
instance_ = this;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/Canon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 13 additions & 3 deletions src/CanonTaskDownloadPicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

err = EdsCreateFileStream(dest.c_str(), kEdsFileCreateDisposition_CreateAlways, kEdsAccess_ReadWrite, &stream);
}
if(err != EDS_ERR_OK) {
Expand All @@ -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);
}
Expand Down
0