graphic function ttg_xcolor()

Each color pixel in the BMP world consist of a Red, Green and Blue intensity between 0 and 255. Using the initials of these colors, each pixel is defined by a RGB triple.
Lets assume a pixel has R = 24, G = 110 and B = 222, calling this function with 'GGG' as third parameter will change this pixel into a (grey) pixel with R = 110, G = 110 and B = 110. The new triple RGB contains the original intensity for Green, Green and Green.
if you want to exchange Red and Green, this parameter should be 'GRB'
Parameters:
1: fullpath to source file2: fullpath to target file
3: recombine new (RGB) triple from old (RGB) triple
***************************** | |
* Tool&Task example program * | |
* ttg_xcolor() * | |
* last compile: 12.07.2022 * | |
***************************** |
LOCAL lx, ly, lh, lw, linfile, loutfile, loh, low, lnh, lnw | |
LOCAL lx0add, ly0add, loutav, loutli, loutlu, lfont | |
ttg_new() | |
ttg_createbmp(148, 148, FORMCOLOR) | |
* the area is divided in 4 rectangles | |
lx = 3 |
&& upper left x coordinate |
ly = 3 |
&& upper left y coordinate |
lh = 74 |
&& half the original space |
lw = 74 - 6 |
&& width and height of subareas |
* resize Logo to lw/lw | |
loutfile = gUserDataTT + 'graphics\pill_resized.bmp' | |
linfile = gUserDataTT+'graphics\tt_pill.bmp' |
&& original logo |
lwh = ttg_getimage(linfile) |
&& width and height original |
low = get_x(lwh) |
&& width of original file |
loh = get_y(lwh) |
&& height of original file |
lmax = max(low, loh) |
&& the longer side must fit |
lfaktor = lw / lmax | |
lwh = ttg_resize(linfile, loutfile, lfaktor) | |
lrw = get_x(lwh) |
&& width of resized file |
lrh = get_y(lwh) |
&& width of resized file |
lx0add = INT((lw - lrw) / 2) |
&& this will center horizontally |
ly0add = INT((lh - lrh) / 2) |
&& this will center vertically |
loutggg = gUserDataTT + "temp\ggg.bmp" | |
loutgrb = gUserDataTT + "temp\grb.bmp" | |
loutbrg = gUserDataTT + "temp\brg.bmp" | |
ttg_xcolor(loutfile, loutggg, "GGG") | |
ttg_xcolor(loutfile, loutgrb, "GRB") | |
ttg_xcolor(loutfile, loutbrg, "BRG") | |
ttg_insertbmp(lx + lx0add, ly + ly0add, loutfile) | |
ttg_insertbmp(74 + lx + lx0add, ly + ly0add, loutggg) | |
ttg_insertbmp(lx + lx0add, 74 + ly + ly0add, loutgrb) | |
ttg_insertbmp(74 + lx + lx0add, 74 + ly + ly0add, loutbrg) | |
ttg_execute(gUserDataTT + "temp\meta.bmp") |
&& insert the images |
*now the metafile holds 4 images and text can be added | |
ttg_openbmp(gUserDataTT + "temp\meta.bmp") |
&& mark the three grey scales |
ttg_font('G', "Courier new", 10, "000", 100, 300, BLUE) | |
ttg_fontselect('G') | |
lx0add = lx0add + 4 |
&& 4 pixels from the corner |
ly0add = ly0add + 4 |
&& 4 pixels from the corner |
ttg_text(74 + lx, ly, "GGG") |
&& upper right -> GGG |
ttg_text(lx, 74 + ly, "GRB") |
&& lower left -> GRB |
ttg_text(74 + lx, 74 + ly, "BRG") |
&& lower right -> BRG |
ttg_execute() | |
ttg_display() |