Skip to content

Commit

Permalink
improve image docs
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Abraham <jade.abraham@hpe.com>
  • Loading branch information
jabraham17 committed Sep 23, 2024
1 parent 24de4d2 commit af1f41f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion modules/packages/Image.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

/* Provides a way to write arrays of pixels to an output image format.
/* Provides a way to read/write arrays of pixels to image formats.
For example, the following code creates a 3x3 array of pixels and writes it to
a BMP file. The array is then scaled by a factor of 2 (creating a 9x9 image)
Expand All @@ -39,6 +39,19 @@ and written to a second BMP file.
writeImage("pixels.bmp", imageType.bmp, arr);
writeImage("pixels2.bmp", imageType.bmp, scale(arr, 2));
In another example, the following code reads a PNG file, removes all green from
the image, and writes it back out to a new JPG file.
.. code-block:: chapel
use Image;
var arr = readImage("input.png", imageType.png);
const fmt = (rgbColor.red, rgbColor.green, rgbColor.blue);
var colors = pixelToColor(arr, format=fmt);
[x in colors] c(1) = 0;
arr = colorToPixel(colors, format=fmt);
writeImage("output.jpg", imageType.jpg, arr);
*/
@unstable("Image is unstable")
Expand Down

0 comments on commit af1f41f

Please sign in to comment.