Rgb get

From Bennu Wiki
Jump to: navigation, search


Syntax

INT rgb_get ( <INT pixel_color > , <POINTER red> , <POINTER green> , <POINTER blue> , [<INT depth>] )

Description

Get access to the memory sections of the color components, these can be accessed with the Offset operator.

The previous get_rgb() is deprecated.

Parameters

INT pixel_color - The color value of a pixel .
POINTER red - Pointer to the level of red in the desired color from 0 to 255.
POINTER green - Pointer to the level of green in the desired color from 0 to 255.
POINTER blue - Pointer to the level of blue in the desired color from 0 to 255.
INT depth - Depth (optional paramter that may be omitted, only in 16 and 32 bit mode). When this parameter is used, the function returns the correct color code for the indicated depth.

Returns

1 : This function always returns a 1.

Notes

The color value's have to be obtained with the Offset operator, and the pixel color value can be obtained with Map_get_pixel().

Example

IMPORT "mod_say";
IMPORT "mod_debug";
IMPORT "mod_key";
IMPORT "mod_map";
IMPORT "mod_video";
IMPORT "mod_wm";
IMPORT "mod_draw";
IMPORT "mod_screen";
IMPORT "mod_mem";
IMPORT "mod_text";

GLOBAL

   int map_id;    // id code of the map to load

   int status;    // status for debugging
   
   // color components
   int my_r;      
   int my_g;
   int my_b; 
   
PROCESS main();

BEGIN

   set_mode(320,200,32);
   
   // load the map
   map_id=load_map("3COCHE.MAP");
   
   // first, we're going to check the r,g,b values of 5 pixels, with the optional
   // depth parameter.
   status=get_rgb(map_get_pixel(0,map_id,0,0), &my_r, &my_g, &my_b ,32);
   
   say("my_r: "+my_r+" my_g: "+my_g+" my_b: "+my_b);  
   say("status: "+status);
   
   status=get_rgb(map_get_pixel(0,map_id,4,0), &my_r, &my_g, &my_b ,32);
   
   say("my_r: "+my_r+" my_g: "+my_g+" my_b: "+my_b);  
   say("status: "+status);
   
   status=get_rgb(map_get_pixel(0,map_id,50,1), &my_r, &my_g, &my_b ,32);
   
   say("my_r: "+my_r+" my_g: "+my_g+" my_b: "+my_b);  
   say("status: "+status);
   
   status=get_rgb(map_get_pixel(0,map_id,13,24), &my_r, &my_g, &my_b, 32);
   
   say("my_r: "+my_r+" my_g: "+my_g+" my_b: "+my_b);  
   say("status: "+status);
   
   status=get_rgb(map_get_pixel(0,map_id,84,40), &my_r, &my_g, &my_b, 32);
   
   say("my_r: "+my_r+" my_g: "+my_g+" my_b: "+my_b);  
   say("status: "+status);
  
   // second, we use the simpler way, that is valid for a bit maps
   say("");
   say("8 bit color codes");
   say(map_get_pixel(0,map_id,0,0));
   say(map_get_pixel(0,map_id,4,0));
   say(map_get_pixel(0,map_id,50,1));
   say(map_get_pixel(0,map_id,13,24));
   say(map_get_pixel(0,map_id,84,40));

   
   LOOP
      IF (key(_esc))
         BREAK;
      END
                  
      FRAME;
   END
END

See also

The articles about the functions, Rgb() and Rgba() for more information, since this function is related to some extend.


mod_map
Globals None
Imported:
FullscreenGraphmodeM7ScalemodeScaleresolutionScaleresolutionaspectratioScaleresolutionorientation
Constants BCLEARCHARSETCP850CHARSETISO8859GANIMATIONSPEEDGANIMATIONSTEPGANIMATIONSTEPSGCENTERXGCENTERYGDEPTHGFRAMESGHEIGHTGPITCHGWIDEGWIDTHGXCENTERGYCENTERNFBFIXEDWIDTHNFBVARIABLEWIDTH
Imported:
BABLENDBALPHABHMIRRORBNOCOLORKEYBSBLENDBTRANSLUCENTBVMIRRORDOUBLEBUFFERHWSURFACEM1024X768M1280X1024M320X200M320X240M320X400M360X240M376X282M400X300M512X384M640X400M640X480M800X600MODE16BITSMODE16BPPMODE2XSCALEMODE8BITSMODE8BPPMODEDOUBLEBUFFERMODEFRAMELESSMODEFULLSCREENMODEHARDWAREMODEMODALMODEWAITVSYNCMODEWINDOW
Functions Bdfload()Centerset()Colorfind()Colorsget()Colorsset()Fade()Fadeoff()Fadeon()Fntload()Fntnew()Fntsave()Fntunload()Fpgadd()Fpgdel()Fpgexists()Fpgload()Fpgnew()Fpgsave()Fpgunload()Getpixel()Glyphget()Glyphset()Graphicinfo()Graphicset()Mapblockcopy()Mapbuffer()Mapclear()Mapclone()Mapdel()Mapexists()Mapgetpixel()Mapinfo()Mapinfoget()Mapinfoset()Mapload()Mapname()Mapnew()Mapput()Mapputpixel()Mapsave()Mapsetname()Mapunload()Mapxput()Mapxputnp()Palclone()Paldel()Palget()Palload()Palmapassign()Palmapgetid()Palmapremove()Palnew()Palrefresh()Palsave()Palset()Palunload()Paletteconvert()Paletteroll()Pcxload()Pngload()Pngsave()Pointget()Pointset()Putpixel()Rgb()Rgbget()Rgba()Rgbaget()