- Timestamp:
- Feb 27, 2008, 1:41:32 AM (14 years ago)
- Location:
- libpipi/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/genethumb/genethumb.c
r2246 r2247 9 9 10 10 i = pipi_load("irc.png"); 11 j = pipi_resize(i, 240, 240);11 j = pipi_resize(i, 180, 180); 12 12 pipi_save(j, "irc.bmp"); 13 13 pipi_free(i); -
libpipi/trunk/pipi/pixels.c
r2228 r2247 17 17 */ 18 18 19 #include "config.h" 20 #include "common.h" 21 19 22 #include <stdio.h> 20 23 #include <stdlib.h> 21 24 #include <string.h> 22 25 23 #include "config.h" 24 #include "common.h" 26 #include <math.h> 25 27 26 28 #include "pipi_internals.h" 27 29 #include "pipi.h" 30 31 #define C2I(p) ((int)255.999*pow(((double)p)/255., 2.2)) 32 #define I2C(p) ((int)255.999*pow(((double)p)/255., 1./2.2)) 28 33 29 34 int pipi_getgray(pipi_image_t const *img, int x, int y, int *g) … … 43 48 int x, int y, int *r, int *g, int *b) 44 49 { 50 uint8_t *pixel; 51 45 52 if(x < 0 || y < 0 || x >= img->width || y >= img->height) 46 53 { … … 51 58 } 52 59 53 *b = (unsigned char)img->pixels[y * img->pitch + x * img->channels]; 54 *g = (unsigned char)img->pixels[y * img->pitch + x * img->channels + 1]; 55 *r = (unsigned char)img->pixels[y * img->pitch + x * img->channels + 2]; 60 pixel = img->pixels + y * img->pitch + x * img->channels; 61 62 *b = C2I((unsigned char)pixel[0]); 63 *g = C2I((unsigned char)pixel[1]); 64 *r = C2I((unsigned char)pixel[2]); 56 65 57 66 return 0; … … 60 69 int pipi_setpixel(pipi_image_t *img, int x, int y, int r, int g, int b) 61 70 { 71 uint8_t *pixel; 72 62 73 if(x < 0 || y < 0 || x >= img->width || y >= img->height) 63 74 return -1; 64 75 65 img->pixels[y * img->pitch + x * img->channels] = b; 66 img->pixels[y * img->pitch + x * img->channels + 1] = g; 67 img->pixels[y * img->pitch + x * img->channels + 2] = r; 76 pixel = img->pixels + y * img->pitch + x * img->channels; 77 78 pixel[0] = I2C(b); 79 pixel[1] = I2C(g); 80 pixel[2] = I2C(r); 68 81 69 82 return 0;
Note: See TracChangeset
for help on using the changeset viewer.