source: project/wiki/eggref/4/stb-image-resize @ 35683

Last change on this file since 35683 was 35683, checked in by mario, 6 months ago

eggref/4/stb-image-resize: add "Repository" section

File size: 1.8 KB
Line 
1== stb-image-resize
2[[toc:]]
3This is a [[http://call-cc.org|CHICKEN]] egg that wraps [[https://github.com/nothings/stb|stb''image''resize.h]] version 0.95
4from Jorge L Rodriguez and friends. It works on [[http://call-cc.org|CHICKEN]] 4 and 5.
5
6== Repository
7
8[[https://github.com/kristianlm/chicken-stb-image-write|https://github.com/kristianlm/chicken-stb-image-write]]
9
10== API
11[[toc:]]
12<procedure> (image-resize pixels width height channels target-width target-height #!key filter region alpha-channel)</procedure>
13
14Takes in raw {{pixels}} (a srfi-4 u8/u16/u32/f32vector) of size
15{{width}}''{{height}}''{{channels}} and returns raw pixels after resizing. The
16returned type is the same as {{pixels}}' of size
17{{target-width}}''{{target-height}}''{{channels}}.
18
19{{channels}} must be an integer between 0 and 64 and keys are processed
20as follows.
21
22* {{filter:}} one of {{box}}, {{triangle}}, {{cubicbspline}}, {{catmullrom}} or
23  {{mitchell}}. The default uses {{catmullrom}} for up-sampling and
24  {{mitchell}} for down-sampling.
25* {{region:}} a vector of 4 elements {{s0 t0 s1 t1}}, representing the
26  UV-coordinates to use as source image. This can be used to crop the
27  image. These values must be in the range of {{[0, 1]}} and represent
28  the fraction of the input image. {{#(0 0 0.5 1)}}, for example, cuts
29  off the right half of the image.
30* {{alpha-channel:}} index of channel which is the alpha channel in the
31  image. supply {{#f}} (default) for no alpha channel.
32
33
34== Examples
35[[toc:]]
36You can try {{example-thumbnail.scm}} like this:
37
38[[image:https://github.com/kristianlm/chicken-stb-image-resize/raw/master/example.png?raw=true|screenshot of running example-thumbnail.scm]]
39
40Or turn a 3x1 greyscale image into a single pixel like this:
41
42{{
43$ csi -R srfi-4 -R stb-image-resize -p '(image-resize (f32vector 0 4 8) 3 1 1   1 1)'
44#f32(4.0)
45}}
46
Note: See TracBrowser for help on using the repository browser.