#include <acknex.h>
#include <default.c>
PANEL* pnlFrom;
PANEL* pnlTo;
void main(){
wait(1);
//create panel to read from
pnlFrom = pan_create("", 1);
pnlFrom.bmap = bmap_createblack(200, 100, 32);
bmap_fill(pnlFrom.bmap, vector(0, 0, 250), 100);
set(pnlFrom, SHOW);
var alpha, formatFrom, formatTo, pixel;
COLOR col;
int x, y, x_max = bmap_width(pnlFrom.bmap), y_max = bmap_height(pnlFrom.bmap);
//create random noise to find
formatFrom = bmap_lock(pnlFrom.bmap, 0);
for(x = 0; x < x_max; x++){
for(y = 0; y < y_max; y++){
vec_set(col, vector(integer(random(255)), integer(random(255)), integer(random(255))));
pixel = pixel_for_vec(col, 100, formatFrom);
pixel_to_bmap(pnlFrom.bmap, x, y, pixel);
}
}
bmap_unlock(pnlFrom.bmap);
//create panel to write to
pnlTo = pan_create("", 1);
pnlTo.bmap = bmap_createblack(200, 100, 32);
bmap_fill(pnlTo.bmap, vector(0, 0, 250), 100);
set(pnlTo, SHOW);
pnlTo.pos_x = 400;
//read all pixel and write only blue to new panel
formatTo = bmap_lock(pnlTo.bmap, 0);
formatFrom = bmap_lock(pnlFrom.bmap, 0);
for(x = 0; x < x_max; x++){
for(y = 0; y < y_max; y++){
pixel = pixel_for_bmap(pnlFrom.bmap, x, y);
pixel_to_vec(col, alpha, formatFrom, pixel);
if(col.blue > 127){
//only draw blue... comment out next 4 lines if not needed
col.blue = 255;
col.green = 0;
col.red = 0;
pixel = pixel_for_vec(col, 100, formatTo);
pixel_to_bmap(pnlTo.bmap, x, y, pixel);
}
}
}
bmap_unlock(pnlTo.bmap);
bmap_unlock(pnlFrom.bmap);
wait(1);
while(!key_enter){ wait(1); }
// while(key_enter){ wait(1); }
pan_remove(pnlFrom);
pan_remove(pnlTo);
main();
}