Category:Action! Bitmap tools: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 8: Line 8:


The following module contains definition of grayscale image.
The following module contains definition of grayscale image.

<lang Action!>MODULE
<lang Action!>MODULE


Line 60: Line 59:


The following module contains definition of RGB color image.
The following module contains definition of RGB color image.

<lang Action!>MODULE
<lang Action!>MODULE


Line 160: Line 158:
ptr.b=c.b
ptr.b=c.b
FI
FI
RETURN

MODULE</lang>

----

=== RGBLINE.ACT ===

The following module contains implementation of Bresenham's algorithm for drawing line on RGB color image.
<lang Action!>MODULE

INCLUDE "H6:RGBIMAGE.ACT" ;from task Bitmap

PROC RgbLine(RgbImage POINTER img
INT x1,y1,x2,y2 RGB POINTER c)
INT dx,dy,sx,sy,err,e2

IF x1>x2 THEN dx=x1-x2
ELSE dx=x2-x1 FI

IF y1>y2 THEN dy=y1-y2
ELSE dy=y2-y1 FI

IF x1<x2 THEN sx=1
ELSE sx=-1 FI

IF y1<y2 THEN sy=1
ELSE sy=-1 FI

IF dx>dy THEN err=dx/2
ELSE err=-dy/2 FI

DO
SetRgbPixel(img,x1,y1,c)
IF x1=x2 AND y1=y2 THEN
EXIT
FI
e2=err
IF e2>-dx THEN
err==-dy
x1==+sx
FI
IF e2<dy THEN
err==+dx
y1==+sy
FI
OD
RETURN
RETURN


Line 169: Line 214:


The following module is designed for loading images in PPM format version 5 (grayscale, binary).
The following module is designed for loading images in PPM format version 5 (grayscale, binary).

<lang Action!>MODULE
<lang Action!>MODULE