Index: /libpipi/trunk/genethumb/genethumb.c
===================================================================
--- /libpipi/trunk/genethumb/genethumb.c	(revision 2246)
+++ /libpipi/trunk/genethumb/genethumb.c	(revision 2247)
@@ -9,5 +9,5 @@
 
     i = pipi_load("irc.png");
-    j = pipi_resize(i, 240, 240);
+    j = pipi_resize(i, 180, 180);
     pipi_save(j, "irc.bmp");
     pipi_free(i);
Index: /libpipi/trunk/pipi/pixels.c
===================================================================
--- /libpipi/trunk/pipi/pixels.c	(revision 2246)
+++ /libpipi/trunk/pipi/pixels.c	(revision 2247)
@@ -17,13 +17,18 @@
  */
 
+#include "config.h"
+#include "common.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "config.h"
-#include "common.h"
+#include <math.h>
 
 #include "pipi_internals.h"
 #include "pipi.h"
+
+#define C2I(p) ((int)255.999*pow(((double)p)/255., 2.2))
+#define I2C(p) ((int)255.999*pow(((double)p)/255., 1./2.2))
 
 int pipi_getgray(pipi_image_t const *img, int x, int y, int *g)
@@ -43,4 +48,6 @@
                   int x, int y, int *r, int *g, int *b)
 {
+    uint8_t *pixel;
+
     if(x < 0 || y < 0 || x >= img->width || y >= img->height)
     {
@@ -51,7 +58,9 @@
     }
 
-    *b = (unsigned char)img->pixels[y * img->pitch + x * img->channels];
-    *g = (unsigned char)img->pixels[y * img->pitch + x * img->channels + 1];
-    *r = (unsigned char)img->pixels[y * img->pitch + x * img->channels + 2];
+    pixel = img->pixels + y * img->pitch + x * img->channels;
+
+    *b = C2I((unsigned char)pixel[0]);
+    *g = C2I((unsigned char)pixel[1]);
+    *r = C2I((unsigned char)pixel[2]);
 
     return 0;
@@ -60,10 +69,14 @@
 int pipi_setpixel(pipi_image_t *img, int x, int y, int r, int g, int b)
 {
+    uint8_t *pixel;
+
     if(x < 0 || y < 0 || x >= img->width || y >= img->height)
         return -1;
 
-    img->pixels[y * img->pitch + x * img->channels] = b;
-    img->pixels[y * img->pitch + x * img->channels + 1] = g;
-    img->pixels[y * img->pitch + x * img->channels + 2] = r;
+    pixel = img->pixels + y * img->pitch + x * img->channels;
+
+    pixel[0] = I2C(b);
+    pixel[1] = I2C(g);
+    pixel[2] = I2C(r);
 
     return 0;
