Debug prints now only in debug builds
This commit is contained in:
parent
9c843e6af3
commit
87dfa5b2a6
23
src/common.c
23
src/common.c
@ -106,24 +106,25 @@ darray* imgToZones(Image* t_img) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void compress(const char *input_file) {
|
void compress(const char *input_file) {
|
||||||
Image* img;
|
Image *img;
|
||||||
darray *zones;
|
darray *zones;
|
||||||
img = newImage();
|
img = newImage();
|
||||||
imageLoadPPM(input_file, img);
|
imageLoadPPM(input_file, img);
|
||||||
zones = imgToZones(img);
|
zones = imgToZones(img);
|
||||||
|
|
||||||
printf("Detected %zu zones\n", darraySize(zones));
|
/* print segments for debug ************************************************/
|
||||||
for(size_t i = 0; i < darraySize(zones); ++i) {
|
DEBUG {
|
||||||
Zone* zone = darrayGet(zones, i);
|
printf("Detected %zu zones\n", darraySize(zones));
|
||||||
printf("\n=== Zone %zu (%d %d %d) ===\n", i, zone->r, zone->g, zone->b);
|
for (size_t i = 0; i < darraySize(zones); ++i) {
|
||||||
for(size_t j = 0; j < darraySize(zone->segments); ++j) {
|
Zone *zone = darrayGet(zones, i);
|
||||||
Segment* segm = darrayGet(zone->segments, j);
|
printf("\n=== Zone %zu (%d %d %d) ===\n", i, zone->r, zone->g, zone->b);
|
||||||
printf("[%d: %d, %d]\t", segm->y, segm->xg, segm->xd);
|
for (size_t j = 0; j < darraySize(zone->segments); ++j) {
|
||||||
|
Segment *segm = darrayGet(zone->segments, j);
|
||||||
|
printf("[%zu: %d, %d]\t", segm->xg / img->x, segm->xg, segm->xd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
|
|
||||||
deleteImage(img);
|
deleteImage(img);
|
||||||
printf("test\n");
|
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,9 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "ERROR: no input file.");
|
fprintf(stderr, "ERROR: no input file.");
|
||||||
help(ARGERROR);
|
help(ARGERROR);
|
||||||
}
|
}
|
||||||
printf("input: %s\noutput: %s\n", argresults.input, argresults.output);
|
DEBUG {
|
||||||
|
printf("input: %s\noutput: %s\n", argresults.input, argresults.output);
|
||||||
|
}
|
||||||
if(argresults.compress) {
|
if(argresults.compress) {
|
||||||
compress(argresults.input);
|
compress(argresults.input);
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,7 +111,9 @@ unsigned long read_data(FILE *t_fp, Image *t_img, unsigned char **t_data,
|
|||||||
unsigned long size;
|
unsigned long size;
|
||||||
/* allocation memoire */
|
/* allocation memoire */
|
||||||
size = t_img->x * t_img->y * 3;
|
size = t_img->x * t_img->y * 3;
|
||||||
printf("Size image %lu %lu => %lu\n", t_img->x, t_img->y, size);
|
DEBUG {
|
||||||
|
printf("Size image %lu %lu => %lu\n", t_img->x, t_img->y, t_img->x * t_img->y);
|
||||||
|
}
|
||||||
*t_data = (unsigned char *)malloc((size_t)size * sizeof(unsigned char));
|
*t_data = (unsigned char *)malloc((size_t)size * sizeof(unsigned char));
|
||||||
assert(*t_data);
|
assert(*t_data);
|
||||||
/* read pixel data from file */
|
/* read pixel data from file */
|
||||||
|
@ -63,7 +63,9 @@ Image *newImage() {
|
|||||||
* \param[in] self Conteneur d’image à détruire
|
* \param[in] self Conteneur d’image à détruire
|
||||||
*/
|
*/
|
||||||
void deleteImage(Image *t_self) {
|
void deleteImage(Image *t_self) {
|
||||||
printf("deleted all pixels\n");
|
DEBUG {
|
||||||
|
printf("deleted all pixels\n");
|
||||||
|
}
|
||||||
darrayDelete(t_self->pixels);
|
darrayDelete(t_self->pixels);
|
||||||
free(t_self);
|
free(t_self);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user