Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
37
Task/Bitmap/REXX/bitmap-1.rexx
Normal file
37
Task/Bitmap/REXX/bitmap-1.rexx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*REXX pgm demonstrates how to handle a simple RGB raster graphics image*/
|
||||
red = '00000000 00000000 11111111'b /*define a red value. */
|
||||
blue = '11111111 00000000 00000000'b /*define a blue value. */
|
||||
blue = 'ff 00 00'x /*another way to define blue. */
|
||||
image.= /*"allocate" an "array" to nulls.*/
|
||||
call RGBfill red /*set the entire image to red. */
|
||||
call RGBset 10,40,blue /*set a pixel to blue. */
|
||||
|
||||
x=10; y=40; pix=RGBget(x,y) /*get the color of a pixel. */
|
||||
hexv = c2x(pix) /*get hex value of pix's color*/
|
||||
binv = x2b(hexv) /* " binary " " " " */
|
||||
|
||||
say 'pixel' x","y '=' binv /*show the binary value of 20,50 */
|
||||
bin3v = left(binv,8) substr(binv,9,8) right(binv,8)
|
||||
say 'pixel' x","y '=' bin3v /*show again, but with spaces. */
|
||||
say /*show a blank between bin & hex.*/
|
||||
say 'pixel' x","y '=' hexv /*show again, but in hexadecimal.*/
|
||||
hex3v = left(hexv,2) substr(hexv,3,2) right(hexv,2)
|
||||
say 'pixel' x","y '=' hex3v /*show again, but with spaces. */
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*──────────────────────────────────RGBFILL subroutine──────────────────*/
|
||||
RGBfill: procedure expose image.; image.=arg(1); return
|
||||
/*──────────────────────────────────RGBGET subroutine───────────────────*/
|
||||
RGBget: procedure expose image.; parse arg Xpixel,Ypixel
|
||||
return image.Xpixel.Ypixel /*get & return the pixel's color.*/
|
||||
/*──────────────────────────────────RGBRASTER subroutine────────────────*/
|
||||
RGBraster: procedure expose image.; parse arg Xsize,Ysize,color; RGB=
|
||||
do x=1 to Xsize; _= /*build raster 1 line at a time. */
|
||||
do y=1 to Ysize /* " a line " pixel " " " */
|
||||
_=_ || image.x.y /*append single pixel to the line*/
|
||||
end /*y*/ /* [↑] all done building a line.*/
|
||||
RGB=RGB || _ /*append a single line to raster.*/
|
||||
end /*x*/ /* [↑] all done building raster.*/
|
||||
return RGB /*return RGB raster to invoker. */
|
||||
/*──────────────────────────────────RGBSET subroutine───────────────────*/
|
||||
RGBset: procedure expose image.; parse arg Xpixel,Ypixel,color
|
||||
image.Xpixel.Ypixel=color; return /*define pixel, return to invoker*/
|
||||
111
Task/Bitmap/REXX/bitmap-2.rexx
Normal file
111
Task/Bitmap/REXX/bitmap-2.rexx
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/* REXX ***************************************************************
|
||||
* Draw a picture from pixels
|
||||
* 16.06.2014 Walter Pachl
|
||||
**********************************************************************/
|
||||
oid='pic.bmp'; 'erase' oid
|
||||
|
||||
blue ='FF0000'x;
|
||||
green='00FF00'x;
|
||||
red ='0000FF'x;
|
||||
white='ffffff'x;
|
||||
black='000000'x;
|
||||
|
||||
w=600 /* width */
|
||||
h=300 /* height */
|
||||
w3=w*3
|
||||
|
||||
bfType ='BM'
|
||||
bfSize ='46000000'x
|
||||
bfReserved ='00000000'x
|
||||
bfOffBits ='36000000'x
|
||||
biSize ='28000000'x
|
||||
biWidth =lend(w)
|
||||
biHeight =lend(h)
|
||||
biPlanes ='0100'x
|
||||
biBitCount ='1800'x
|
||||
biCompression ='00000000'x
|
||||
biSizeImage ='10000000'x
|
||||
biXPelsPerMeter='00000000'x
|
||||
biYPelsPerMeter='00000000'x
|
||||
biClrUsed ='00000000'x
|
||||
biClrImportant ='00000000'x
|
||||
|
||||
s=bfType||,
|
||||
bfSize||,
|
||||
bfReserved||,
|
||||
bfOffBits||,
|
||||
biSize||,
|
||||
biWidth||,
|
||||
biHeight||,
|
||||
biPlanes||,
|
||||
biBitCount||,
|
||||
biCompression||,
|
||||
biSizeImage||,
|
||||
biXPelsPerMeter||,
|
||||
biYPelsPerMeter||,
|
||||
biClrUsed||,
|
||||
biClrImportant
|
||||
|
||||
pic=copies(red,w*h) /* fill the rectangle with color red */
|
||||
Call rect 100,100,180,180,green /* draw a green rectangle */
|
||||
Call rect 100,100,160,160,blue /* and a blue rectangle within that */
|
||||
Call dot 120,120,white /* one pixel is hardly visible */
|
||||
Do x=98 To 102 /* draw a square of 25 pixels */
|
||||
Do y=98 To 102
|
||||
Call dot x,y,white
|
||||
End
|
||||
End
|
||||
Call charout oid,s||pic /* write the picture to file */
|
||||
dmy=col(97,98)
|
||||
dmy=col(98,98)
|
||||
Exit
|
||||
|
||||
lend: Procedure
|
||||
/**********************************************************************
|
||||
* compute the representation of a number (little endian)
|
||||
**********************************************************************/
|
||||
Parse Arg n
|
||||
res=reverse(d2c(n,4))
|
||||
rev=reverse(res)
|
||||
say 'lend:' arg(1) '->' c2x(res) '=>' c2d(rev)
|
||||
Return res
|
||||
|
||||
rect: Procedure Expose pic w h w3
|
||||
/**********************************************************************
|
||||
* Fill a rectangle with center at x,y and width/height = wr/hr
|
||||
**********************************************************************/
|
||||
Parse Arg x,y,wr,hr,color
|
||||
Say x y wr hr c2x(color)
|
||||
i=w3*(y-1)+3*(x-1)+1 /* Pixel position of center */
|
||||
ia=max(w3*(y-1)+1,i-3*(wr%2)) /* position of left border */
|
||||
ib=min(i+3*wr%2,w3*y) /* position of right border */
|
||||
lc=ib-ia /* length of horizontal line */
|
||||
If lc>=0 Then Do
|
||||
os=copies(color,lc%3) /* the horizontal line */
|
||||
Do hi=-hr%2 to hr%2 /* loop from lower to upper border*/
|
||||
i=trunc(ia+w3*hi) /* position of line's left border */
|
||||
If i>1 Then Do
|
||||
pic=overlay(os,pic,i) /* put the line into the picture */
|
||||
j=i%w3
|
||||
End
|
||||
End
|
||||
End
|
||||
Return
|
||||
|
||||
dot: Procedure Expose pic w h w3
|
||||
/**********************************************************************
|
||||
* Put a dot at position x/y into the picture
|
||||
**********************************************************************/
|
||||
Parse Arg x,y,color
|
||||
i=w3*(y-1)+3*(x-1)
|
||||
pic=overlay(color,pic,i+1)
|
||||
Return
|
||||
|
||||
col: Procedure Expose pic w h w3
|
||||
/**********************************************************************
|
||||
* get the color at position x/y
|
||||
**********************************************************************/
|
||||
Parse Arg x,y,color
|
||||
i=w3*(y-1)+3*(x-1)
|
||||
say 'color at pixel' x'/'y'='c2x(substr(pic,i+1,3))
|
||||
Return c2x(substr(pic,i+1,3))
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*REXX program shows how to handle a simple RGB raster graphics image. */
|
||||
image.='00 00 00'x /*set entire array to hex zeroes.*/
|
||||
|
||||
red='00000000 00000000 11111111'b /*define a red value. */
|
||||
image.=red /*set the entire array to red. */
|
||||
|
||||
blue='11111111 00000000 00000000'b /*define a blue value. */
|
||||
blue='ff 00 00'x /*another way to define blue. */
|
||||
image.10.40=blue /*set a particular pixel. */
|
||||
|
||||
x=20
|
||||
y=50
|
||||
aPIXcolor=image.x.y /*obtain the color of a pixel. */
|
||||
hexv=c2x(aPixcolor) /*get the binary value of 20,50. */
|
||||
binv=x2b(hexv) /*get the binary value of 20,50. */
|
||||
|
||||
say 'pixel' x","y '=' binv /*show the binary value of 20,50 */
|
||||
bin3v=left(binv,8) substr(binv,9,8) right(binv,8)
|
||||
say 'pixel' x","y '=' bin3v /*show again, but with spaces. */
|
||||
|
||||
say 'pixel' x","y '=' hexv /*show again, but in hexadecimal.*/
|
||||
hex3v=left(hexv,2) substr(hexv,3,2) right(hexv,2)
|
||||
say 'pixel' x","y '=' hex3v /*show again, but with spaces. */
|
||||
|
||||
RGB= /*start with a clean slate. */
|
||||
xSize=500 /*size of the X axis. */
|
||||
YSize=800 /* " " " Y " */
|
||||
|
||||
do x=1 to xSize
|
||||
do y=1 to Ysize
|
||||
RGB=RGM || image.x.y /*build RBG one pixel at a time.*/
|
||||
end /*y*/
|
||||
end /*x*/
|
||||
|
||||
return RGM /*return the RGB image to invoker*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue