Krita Source Code Documentation
Loading...
Searching...
No Matches
scaletab.c
Go to the documentation of this file.
1/* Run-time scaletable computation for Xcftools
2 *
3 * This file was written by Henning Makholm <henning@makholm.net>
4 * It is hereby in the public domain.
5 *
6 * In jurisdictions that do not recognise grants of copyright to the
7 * public domain: I, the author and (presumably, in those jurisdictions)
8 * copyright holder, hereby permit anyone to distribute and use this code,
9 * in source code or binary form, with or without modifications. This
10 * permission is world-wide and irrevocable.
11 *
12 * Of course, I will not be liable for any errors or shortcomings in the
13 * code, since I give it away without asking any compenstations.
14 *
15 * If you use or distribute this code, I would appreciate receiving
16 * credit for writing it, in whichever way you find proper and customary.
17 */
18
19#include "pixels.h"
20#ifndef PRECOMPUTED_SCALETABLE
21
22uint8_t scaletable[256][256] ;
24
25void
27{
28 unsigned p, q, r ;
29 if( ok_scaletable ) return ;
30 for( p = 0 ; p < 128 ; p++ )
31 for( q = 0 ; q <= p ; q++ ) {
32 r = (p*q+127)/255 ;
33 scaletable[p][q] = scaletable[q][p] = r ;
34 scaletable[255-p][q] = scaletable[q][255-p] = q-r ;
35 scaletable[p][255-q] = scaletable[255-q][p] = p-r ;
36 scaletable[255-p][255-q] = scaletable[255-q][255-p] = (255-q)-(p-r) ;
37 }
38 ok_scaletable = 1 ;
39}
40
41#endif
42
const Params2D p
void mk_scaletable(void)
Definition scaletab.c:26
uint8_t scaletable[256][256]
Definition scaletab.c:22
int ok_scaletable
Definition scaletab.c:23