Example n.5 - Pixels Handling

Top  Previous  Next

In this example we'll show how drawing shapes on the current image.

 

//extracting image width and height

width:=ImgGetWidth(_CurrentImage);

height:=ImgGetHeight(_CurrentImage);

 

//value for black color

color:=ImgGetBlackValue(_CurrentImage);

 

ApplicationLog('Drawing in process...');

 

// printing a black border around current image

for x:=0 to width-1 do

 begin

         ImgSetPixel(_CurrentImage,x,0,color);

                 ImgSetPixel(_CurrentImage,x,(height-1),color);

       end;

for y:=0 to height-1 do

 begin

         ImgSetPixel(_CurrentImage,0,y,color);

         ImgSetPixel(_CurrentImage,(width-1),y,color);

 end;

end;

 

ApplicationLog('Drawing done !');

 

 

The first step is to require size  (ImgGetWidth, ImgGetHeight) and black color (ImgBlackValue) information.

 

Finally, implemented with two for cycles, we draw a black rectangle of 1 pixel on the border of the current image; for this purpose we use ImgSetPixel , that (passing image handle, point coordinates and color code) colors a specific pixel.