Show
Ignore:
Timestamp:
02/23/09 18:40:45 (17 months ago)
Author:
anthony_rowe
Message:

hsv ppm grab updated

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/projects/hsv-ppm-grab/main.c

    r504 r560  
    33#include <stdbool.h> 
    44#include <cc3_hsv.h> 
    5 #include "cc3.h" 
     5#include <cc3.h> 
    66 
    77 
     
    3636    // Check if files exist, if they do then skip over them 
    3737    do { 
    38       snprintf(filename, 16, "c:/img%.5d.ppm", i); 
    39       //snprintf(filename, 16, "img%.5d.ppm", i); 
     38        #ifndef VIRTUAL_CAM 
     39                snprintf(filename, 16, "c:/img%.5d.ppm", i); 
     40        #else 
     41                snprintf(filename, 16, "img%.5d.ppm", i); 
     42        #endif 
    4043      f = fopen(filename, "r"); 
    4144      if (f != NULL) { 
     
    102105 
    103106  cc3_pixbuf_load (); 
    104   uint8_t *row = cc3_malloc_rows(1); 
     107  cc3_pixel_t *row = (cc3_pixel_t*) cc3_malloc_rows(1); 
    105108 
    106109  size_x = cc3_g_pixbuf_frame.width; 
    107110  size_y = cc3_g_pixbuf_frame.height; 
    108111 
    109   fprintf(f,"P6\n%d %d\n255\n",size_x,size_y ); 
     112  fprintf(f,"P6\n%lu %lu\n255\n",size_x,size_y ); 
    110113 
    111114  time = cc3_timer_get_current_ms(); 
     
    113116    cc3_pixbuf_read_rows(row, 1); 
    114117    cc3_rgb2hsv_row(row,size_x);  // This line will convert the row to HSV 
    115     for (x = 0; x < size_x * 3U; x++) { 
    116       uint8_t p = row[x]; 
    117       if (fputc(p, f) == EOF) { 
    118         perror("fputc failed"); 
    119       } 
     118    for (x = 0; x < size_x; x++) { 
     119      uint8_t h,s,v; 
     120        h = row[x].channel[CC3_CHANNEL_HUE]; 
     121        s = row[x].channel[CC3_CHANNEL_SAT]; 
     122        v = row[x].channel[CC3_CHANNEL_VAL]; 
     123        if (fputc(h, f) == EOF) { perror("fputc failed\n"); } 
     124        if (fputc(s, f) == EOF) { perror("fputc failed\n"); } 
     125        if (fputc(v, f) == EOF) { perror("fputc failed\n"); } 
    120126    } 
    121127    fprintf(stderr, ".");