Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Screw that quantum crap. Using normalized doubles now instead. Still …

…segfaults.
  • Loading branch information...
commit b455eb3c525d10bba6b0096d4224b65f78575ea6 1 parent 97faa64
@meltingice authored
Showing with 13 additions and 18 deletions.
  1. BIN  bin/caman-cli
  2. +12 −17 src/render.c
  3. +1 −1  src/render.h
View
BIN  bin/caman-cli
Binary file not shown
View
29 src/render.c
@@ -25,31 +25,26 @@ void camanProcessFilter(CamanInstance caman, double adjust,
break;
for (x = 0; x < (long) width; x++) {
- pixel->red = (CamanColor)(PixelGetRedQuantum(pixels[x]) / (CamanColor) QuantumRange);
- pixel->green = (CamanColor)(PixelGetGreenQuantum(pixels[x]) / (CamanColor)QuantumRange);
- pixel->blue = (CamanColor)(PixelGetBlueQuantum(pixels[x]) / (CamanColor) QuantumRange);
-
- pixel->red *= 255.0;
- pixel->green *= 255.0;
- pixel->blue *= 255.0;
+ pixel->red = PixelGetRed(pixels[x]) * 255;
+ pixel->green = PixelGetGreen(pixels[x]) * 255;
+ pixel->blue = PixelGetBlue(pixels[x]) * 255;
printf("Before: %f %f %f\n", pixel->red, pixel->green, pixel->blue);
filter(pixel, adjust);
clampRGBA(pixel);
- //printf("After: %f %f %f\n", pixel->red, pixel->green, pixel->blue);
- printf("After: %d %d %d\n", getCamanColorQuantum(pixel->red), getCamanColorQuantum(pixel->green), getCamanColorQuantum(pixel->blue));
+ printf("After: %f %f %f\n", pixel->red, pixel->green, pixel->blue);
- PixelSetRedQuantum(pixels[x], getCamanColorQuantum(pixel->red));
- PixelSetGreenQuantum(pixels[x], getCamanColorQuantum(pixel->green));
- PixelSetBlueQuantum(pixels[x], getCamanColorQuantum(pixel->blue));
+ PixelSetRed(pixels[x], getCamanColorNormalized(pixel->red));
+ PixelSetGreen(pixels[x], getCamanColorNormalized(pixel->green));
+ PixelSetBlue(pixels[x], getCamanColorNormalized(pixel->blue));
}
-
+
PixelSyncIterator(iterator);
}
DestroyPixelIterator(iterator);
- //free(pixel);
+ free(pixel);
}
void clampRGBA(CamanRGBA pixel) {
@@ -61,9 +56,9 @@ void clampRGBA(CamanRGBA pixel) {
if (pixel->blue > 255) pixel->blue = 255;
}
-Quantum getCamanColorQuantum(CamanColor color) {
+double getCamanColorNormalized(CamanColor color) {
if (color < 0) return 0;
- if (color > 255) return QuantumRange;
+ if (color > 255) return 1.0;
- return (Quantum)((color / 255) * (CamanColor) QuantumRange);
+ return color / 255;
}
View
2  src/render.h
@@ -4,6 +4,6 @@
/* Function prototypes */
void camanProcessFilter(CamanInstance, double, void (*filter)(CamanRGBA, CamanColor));
void clampRGBA(CamanRGBA);
-Quantum getCamanColorQuantum(CamanColor);
+double getCamanColorNormalized(CamanColor);
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.