array size

Fork of JPEGCamera by Hiroshi Yamaguchi

Revision:
2:609037d25e10
Parent:
1:27417b6a951d
--- a/JPEGCamera.cpp	Thu Nov 17 13:59:40 2011 +0000
+++ b/JPEGCamera.cpp	Sat Aug 22 10:12:47 2015 +0000
@@ -34,12 +34,34 @@
 }
 
 bool JPEGCamera::isProcessing() {
+   // printf("Im here/n2");
     return state == PROCESSING;
 }
 
+bool JPEGCamera::processPicture_ref() {
+    if (state == PROCESSING) {
+        if (address < imageSize) {
+            char data[1024];
+            int size = readData(data, min(sizeof(data), imageSize - address), address);
+            int ret = fwrite(data, size, 1, fp);
+            if (ret > 0)
+                address += size;
+            if (ret == 0 || address >= imageSize) {
+                stopPictures();
+                fclose(fp);
+                wait(0.1); // ????
+                state = ret > 0 ? READY : ERROR;
+            }
+        }
+    }
+    return state == PROCESSING || state == READY;
+}
+
+
 bool JPEGCamera::takePicture(char *filename) {
+    //printf("Im here1O/n");
     if (state == READY) {
-        fp = fopen(filename, "wb");
+        fp = fopen(filename, "wb");      
         if (fp != 0) {
             if (takePicture()) {
                 imageSize = getImageSize();
@@ -55,6 +77,7 @@
             state = ERROR;
         }
     }
+   // printf("Im here1C/n");
     return state != ERROR;
 }
 
@@ -104,6 +127,10 @@
     return ret == 4 && buf[0] == 0x76;
 }
 
+int JPEGCamera::getSizeOfimage(void){
+    return imageSize;
+}
+
 int JPEGCamera::getImageSize() {
     char buf[9] = {0x56, 0x00, 0x34, 0x01, 0x00};
     int ret = sendReceive(buf, sizeof buf, 9);
@@ -135,7 +162,7 @@
 
     int i = 0;
     while (i < size && timer.read_ms() < timeout) {
-        if (readable())
+            if (readable())
             buf[i++] = getc();
     }