Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 83 lines (57 sloc) 1.612 kb
2df3535a » Arnar Mar Hrafnkelsson
2001-05-16 Added map.c which implements mapping images through tables.
1 /*
2 =head1 NAME
3
4 map.c - inplace image mapping and related functionality
5
6 =head1 SYNOPSIS
7
8 i_map(srcimage, coeffs, outchans, inchans)
9
10 =head1 DESCRIPTION
11
12 Converts images from one format to another, typically in this case for
13 converting from RGBA to greyscale and back.
14
15 =over
16
17 =cut
18 */
19
92bda632 » Tony Cook
2006-01-10 - start of external Imager API access:
20 #include "imager.h"
2df3535a » Arnar Mar Hrafnkelsson
2001-05-16 Added map.c which implements mapping images through tables.
21
22
23 /*
24 =item i_map(im, mapcount, maps, chmasks)
25
26 maps im inplace into another image.
27
28 Each map is a unsigned char array of 256 entries, its corresponding
29 channel mask is the same numbered entry in the chmasks array.
30 If two maps apply to the same channel then the second one is used.
31 If no map applies to a channel then that channel is not altered.
32 mapcount is the number of maps.
33
34 =cut
35 */
36
37 void
85ac7c04 » Arnar Mar Hrafnkelsson
2001-05-16 Simplified interface.
38 i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask) {
2df3535a » Arnar Mar Hrafnkelsson
2001-05-16 Added map.c which implements mapping images through tables.
39 i_color *vals;
8d14daab »
2011-06-14 switch to using size_t and i_img_dim strictly
40 i_img_dim x, y;
a659442a » Tony Cook
2005-01-24 - eliminate unused variables and static functions
41 int i, ch;
b07bc64b » Tony Cook
2006-11-19 avoid various compiler warnings
42 int minset = -1, maxset = 0;
2df3535a » Arnar Mar Hrafnkelsson
2001-05-16 Added map.c which implements mapping images through tables.
43
40eba1ea » Arnar Mar Hrafnkelsson
2001-05-16 Fixes to i_map function and map method. Added a testcase for both.
44 mm_log((1,"i_map(im %p, maps %p, chmask %u)\n", im, maps, mask));
2df3535a » Arnar Mar Hrafnkelsson
2001-05-16 Added map.c which implements mapping images through tables.
45
46 if (!mask) return; /* nothing to do here */
47
48 for(i=0; i<im->channels; i++)
49 if (mask & (1<<i)) {
50 if (minset == -1) minset = i;
51 maxset = i;
52 }
40eba1ea » Arnar Mar Hrafnkelsson
2001-05-16 Fixes to i_map function and map method. Added a testcase for both.
53
54 mm_log((1, "minset=%d maxset=%d\n", minset, maxset));
55
2df3535a » Arnar Mar Hrafnkelsson
2001-05-16 Added map.c which implements mapping images through tables.
56 vals = mymalloc(sizeof(i_color) * im->xsize);
40eba1ea » Arnar Mar Hrafnkelsson
2001-05-16 Fixes to i_map function and map method. Added a testcase for both.
57
2df3535a » Arnar Mar Hrafnkelsson
2001-05-16 Added map.c which implements mapping images through tables.
58 for (y = 0; y < im->ysize; ++y) {
59 i_glin(im, 0, im->xsize, y, vals);
60 for (x = 0; x < im->xsize; ++x) {
61 for(ch = minset; ch<=maxset; ch++) {
85ac7c04 » Arnar Mar Hrafnkelsson
2001-05-16 Simplified interface.
62 if (!maps[ch]) continue;
40eba1ea » Arnar Mar Hrafnkelsson
2001-05-16 Fixes to i_map function and map method. Added a testcase for both.
63 vals[x].channel[ch] = maps[ch][vals[x].channel[ch]];
2df3535a » Arnar Mar Hrafnkelsson
2001-05-16 Added map.c which implements mapping images through tables.
64 }
65 }
66 i_plin(im, 0, im->xsize, y, vals);
67 }
68 myfree(vals);
69 }
70
71 /*
72 =back
73
74 =head1 SEE ALSO
75
76 Imager(3)
77
78 =head1 AUTHOR
79
80 Arnar M. Hrafnkelsson <addi@umich.edu>
81
82 =cut
83 */
Something went wrong with that request. Please try again.