/** * Create a colored image. * @param color The color of the image (a hex value). * @param width The width of the image. * @param height The height of the image. * @return Handle to the image. The image needs to be * deallocated with maDestoryObject. */ MAHandle ScreenColorList::createColorImage(int color, int width, int height) { MAHandle image = maCreatePlaceholder(); maCreateDrawableImage(image, width, height); MAHandle previousDrawTarget = maSetDrawTarget(image); maSetColor(color); maFillRect(0, 0, width, height); maSetDrawTarget(previousDrawTarget); return image; }
int MAMain() { int x=0, y=0, dx=1, dy=1; int scrW, scrH; int srcW, srcH; { int srcSize = maGetImageSize(SIMG); srcW = EXTENT_X(srcSize); srcH = EXTENT_Y(srcSize); } maCreateDrawableImage(TIMG, srcW,srcH); maSetDrawTarget(TIMG); maSetColor(0); //black maFillRect(0,0, srcW,srcH); maDrawImage(SIMG, 0,0); maSetColor(0xff0000); //red maLine(0,0, srcW,srcH); maLine(srcW,0, 0,srcH); maSetDrawTarget(HANDLE_SCREEN); { int scrSize = maGetScrSize(); scrW = EXTENT_X(scrSize); scrH = EXTENT_Y(scrSize); } while(1) { //int then = maGetMilliSecondCount(); maSetColor(0); //black maFillRect(0,0, scrW,scrH); maDrawImage(TIMG, x, y); if((dx > 0 && x + srcW > scrW) || (dx < 0 && x < 0)) { dx = -dx; } if((dy > 0 && y + srcH > scrH) || (dy < 0 && y < 0)) { dy = -dy; } x += dx; y += dy; maUpdateScreen(); /*{ int now = maGetMilliSecondCount(); int time_padding = 10 - (now - then); if(time_padding > 0) maSleep(time_padding); }*/ } }
void testDrawableImages() { const unsigned int colors[] = { 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff, }; const unsigned int NUMCOLORS = sizeof(colors)/sizeof(int); unsigned int colors2[NUMCOLORS]; MAHandle testImg = maCreatePlaceholder(); printf("testing resources\n"); int res = maCreateDrawableImage(testImg, NUMCOLORS, 1); assert("maCreateImageRaw", res == RES_OK); MAExtent e1 = maGetImageSize(testImg); assert("maGetImageSize", e1 == EXTENT(NUMCOLORS,1)); maSetDrawTarget(testImg); for(unsigned int i = 0; i < NUMCOLORS; i++) { maSetColor(colors[i]); maPlot(i, 0); } MARect rect = {0, 0, NUMCOLORS, 1}; maSetDrawTarget(0); maGetImageData(testImg, colors2, &rect, NUMCOLORS); assert( "testing drawable image res", (memcmp(colors, colors2, sizeof(colors)) == 0) ); }
VisueelScherm::VisueelScherm( WeerData* weerData ) { //sla de weerdata op in het attribuut this->weerData = weerData; //ken font en skin toe this->font = new Font(RES_FONT); this->skin = new WidgetSkin(RES_SELECTED, RES_UNSELECTED, 16,32,16,32,false, false); //maak een achtergrond label om alle andere widgets in op te slaan, en te tonen Label* achtergrond = new Label(0,0,0,0,NULL); achtergrond->setBackgroundColor(0x000000); //maak een listbox waar update en visueelknop aan toegevoegd worden this->listBox = new ListBox(5,0,150,40,achtergrond); //knop om data te updaten this->updateKnop = new Label(5,0,50,25,achtergrond, "Update!", 0, font); this->updateKnop->setSkin( this->skin ); //knop om naar visueel scherm te schakelen this->textueelKnop = new Label(55,0,50,25,achtergrond, "Visueel!", 0, font); this->textueelKnop->setSkin( this->skin ); //staafdiagram //maak eerst een placeholder this->diagramTekening = maCreatePlaceholder(); //laat de placeholder tekenbaar zijn maCreateDrawableImage( this->diagramTekening, EXTENT_X( maGetScrSize() ), EXTENT_Y( maGetScrSize() ) - 30 ); //mak een nieuwe image met de placeholder this->diagramImage = new Image( 0, 30, EXTENT_X( maGetScrSize() ), EXTENT_Y( maGetScrSize() ) - 30, achtergrond, true, true, this->diagramTekening ); this->setMain( achtergrond ); this->update(); }