Skip to content
Browse files

running well in 007/xp/32/VS2010 with Canon 5D/2

  • Loading branch information...
1 parent 21ee673 commit 1cad2d75e52cb4e7edf80421451012acc6764fbc @elliotwoods committed Aug 21, 2011
Showing with 37 additions and 15 deletions.
  1. +11 −1 CanonCameraWrapper.cpp
  2. +26 −14 CanonCameraWrapper.h
View
12 CanonCameraWrapper.cpp
@@ -689,6 +689,10 @@
}
easyRelease(stream);
+
+ if (success)
+ evtImageDownloaded.notify(this, getLastImagePath());
+
return success;
}
@@ -717,6 +721,8 @@
if(event == kEdsObjectEvent_DirItemRequestTransfer) {
printf("kEdsObjectEvent_DirItemRequestTransfer!\n");
}
+
+ return 0;
}
//------------------------------------------------------------------------
@@ -765,6 +771,8 @@
if(inEvent == kEdsPropertyEvent_PropertyDescChanged) {
printf("kEdsPropertyEvent_PropertyDescChanged - %s\n", prop.c_str());
}
+
+ return 0;
}
//----------------------------------------------------------------------------
@@ -792,7 +800,9 @@
}
if(inEvent == kEdsStateEvent_BulbExposureTime) {
printf("kEdsStateEvent_BulbExposureTime");
- }
+ }
+
+ return 0;
}
View
40 CanonCameraWrapper.h
@@ -12,12 +12,10 @@
#include "EDSDK.h"
#include "EDSDKErrors.h"
#include "EDSDKTypes.h"
+#include "Freeimage.h"
-#define HAVE_OF
-#ifdef HAVE_OF
- #include "ofImage.h"
-#endif
+#include "ofMain.h"
#ifndef BYTE
#define BYTE unsigned char
@@ -39,6 +37,19 @@ static void easyRelease(EdsBaseRef &ref){
}
}
+static void putBmpIntoPixels(FIBITMAP * bmp, ofPixels &pix){
+ int width = FreeImage_GetWidth(bmp);
+ int height = FreeImage_GetHeight(bmp);
+ int bpp = FreeImage_GetBPP(bmp);
+ int bytesPerPixel = bpp / 8;
+ //------------------------------------------
+ // call the allocation routine (which checks if really need to allocate) here
+
+ pix.allocate(width, height, OF_IMAGE_COLOR);
+ FreeImage_ConvertToRawBits(pix.getPixels(), bmp, width*bytesPerPixel, bpp, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, true); // get bits
+}
+
+
class memoryImage : public ofImage{
public:
@@ -75,12 +86,12 @@ class memoryImage : public ofImage{
//FreeImage_FlipVertical(tmpBmp);
- putBmpIntoPixels(tmpBmp, myPixels);
+ putBmpIntoPixels(tmpBmp, getPixelsRef());
width = FreeImage_GetWidth(tmpBmp);
height = FreeImage_GetHeight(tmpBmp);
bpp = FreeImage_GetBPP(tmpBmp);
- swapRgb(myPixels);
+ swapRgb(getPixelsRef());
FreeImage_Unload(tmpBmp);
FreeImage_CloseMemory(hmem);
@@ -91,16 +102,16 @@ class memoryImage : public ofImage{
//shouldn't have to redefine this but a gcc bug means we do
inline void swapRgb(ofPixels &pix){
- if (pix.bitsPerPixel != 8){
- int sizePixels = pix.width*pix.height;
+ if (pix.getBitsPerPixel() != 8){
+ int sizePixels = pix.getWidth()*pix.getHeight();
int cnt = 0;
unsigned char temp;
- int byteCount = pix.bitsPerPixel/8;
+ int byteCount = pix.getBitsPerPixel()/8;
while (cnt < sizePixels){
- temp = pix.pixels[cnt*byteCount];
- pix.pixels[cnt*byteCount] = pix.pixels[cnt*byteCount+2];
- pix.pixels[cnt*byteCount+2] = temp;
+ temp = pix.getPixels()[cnt*byteCount];
+ pix.getPixels()[cnt*byteCount] = pix.getPixels()[cnt*byteCount+2];
+ pix.getPixels()[cnt*byteCount+2] = temp;
cnt++;
}
}
@@ -120,6 +131,7 @@ class CanonCameraWrapper{
CanonCameraWrapper();
~CanonCameraWrapper();
+ ofEvent<string> evtImageDownloaded;
//---------------------------------------------------------------------
// SDK AND SESSION MANAGEMENT
//---------------------------------------------------------------------
@@ -174,8 +186,8 @@ class CanonCameraWrapper{
// MISC EXTRA STUFF
//---------------------------------------------------------------------
- string getLastImageName(); //The full path of the last downloaded image
- string getLastImagePath(); //The name of the last downloaded image
+ string getLastImageName(); //The name of the last downloaded image
+ string getLastImagePath(); //The full path of the last downloaded image
//This doesn't work perfectly - for some reason it can be one image behind
//something about how often the camera updates the SDK.

0 comments on commit 1cad2d7

Please sign in to comment.
Something went wrong with that request. Please try again.