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

Last change on this file since 35578 was 35578, checked in by kristianlm, 2 years ago

obs: stb-image-resize using markdown-svnwiki

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