Show a basic storage type to handle a simple RGB raster graphics image,
and some primitive associated functions.

If possible provide a function to allocate an uninitialised image,
given its width and height, and provide 3 additional functions:

   one to fill an image with a plain RGB color,
   one to set a given pixel with a color,
   one to get the color of a pixel.


(If there are specificities about the storage or the allocation, explain those.)

These functions are used as a base for the articles in the category raster graphics operations, 
and a basic output function to check the results
is available in the article write ppm file.




#11 = 400		// Width of the image
#12 = 300		// Height of the image
 
// Create an empty RGB image and fill it with black color
//
File_Open("|(VEDIT_TEMP)\pixel.data", OVERWRITE+NOEVENT)
BOF
Del_Char(ALL)
#10 = Buf_Num
Repeat(#11 * #12) {
    Ins_Char(0, COUNT, 3)
}
 
// Fill the image with dark blue color
//
#5 = 0				// Red
#6 = 0				// Green
#7 = 64				// Blue
Call("FILL_IMAGE")
 
// Draw one pixel in orange color
//
#1 = 100			// x
#2 = 50				// y
#5 = 255 #6 = 128 #7 = 0	// Orange color
Call("DRAW_PIXEL")
 
// Get the color of a pixel
//
#1 = 10
#2 = 3
Call("GET_COLOR")
 
Buf_Switch(#10) Buf_Quit(OK)
Return
 
/////////////////////////////////////////////////////////////////////
//
//  Fill image with given color: #5 = Red, #6 = Green, #7 = Blue
//
:FILL_IMAGE:
BOF
Repeat (File_Size/3) {
    IC(#5,OVERWRITE) IC(#6,OVERWRITE) IC(#7,OVERWRITE)
}
Return
 
/////////////////////////////////////////////////////////////////////
//
//  Daw a pixel. #1 = x, #2 = y
//
:DRAW_PIXEL:
Goto_Pos((#1 + #2*#11)*3)
IC(#5,OVERWRITE) IC(#6,OVERWRITE) IC(#7,OVERWRITE)
Return
 
/////////////////////////////////////////////////////////////////////
//
//  Get color of a pixel. #1 = x, #2 = y
//  Return: #5 = Red, #6 = Green, #7 = Blue
//
:GET_COLOR:
Goto_Pos((#1 + #2*#11)*3)
#5 = Cur_Char
#6 = Cur_Char(1)
#7 = Cur_Char(2)
Return