June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,17 +1,21 @@
|
|||
/*REXX program to write a PPM formatted image file, P6 (binary). */
|
||||
oFID = 'IMAGE.PPM' /*name of the output file. */
|
||||
green = '00 ff 00'x
|
||||
image. = green /*define all IMAGE RGB's to green*/
|
||||
width = 20 /*define the width of IMAGE. */
|
||||
height = 20 /* " " height " " */
|
||||
sep = '9'x
|
||||
call put 'P6'width||sep||height||sep||255||sep /*write header info.*/
|
||||
|
||||
do j =1 for width
|
||||
do k=1 for height
|
||||
call put image.j.k /*write IMAGE, 3 bytes at a time.*/
|
||||
end /*k*/
|
||||
end /*j*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*─────────────────────────────────────subroutines──────────────────────*/
|
||||
put: call charout oFID,arg(1); return /*write out character(s) to file.*/
|
||||
/*REXX program writes a PPM formatted image file, also known as a P6 (binary) file. */
|
||||
green = 00ff00 /*define a pixel with the color green. */
|
||||
parse arg oFN width height color . /*obtain optional arguments from the CL*/
|
||||
if oFN=='' | oFN=="," then oFN='IMAGE' /*Not specified? Then use the default.*/
|
||||
if width=='' | width=="," then width= 20 /* " " " " " " */
|
||||
if height=='' | height=="," then height= 20 /* " " " " " " */
|
||||
if color=='' | color=="," then color= green /* " " " " " " */
|
||||
oFID= oFN'.PPM' /*define oFID by adding an extension.*/
|
||||
@. = x2c(color) /*set all pixels of image a hex color. */
|
||||
$ = '9'x /*define the separator (in the header).*/
|
||||
# = 255 /* " " max value for all colors. */
|
||||
call charout oFID, , 1 /*set the position of the file's output*/
|
||||
call charout oFID,'P6'width || $ || height || $ || # || $ /*write file header info. */
|
||||
_=
|
||||
do j =1 for width
|
||||
do k=1 for height; _=_ || @.j.k /*write the PPM file, 1 pixel at a time*/
|
||||
end /*k*/ /* ↑ a pixel contains three bytes, */
|
||||
end /*j*/ /* └────which defines the pixel's color*/
|
||||
call charout oFID, _ /*write the image's raster to the file.*/
|
||||
call charout oFID /*close the output file just to be safe*/
|
||||
/*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue