Variable blendExpression::evaluate() { ImageObject* bottom = store->getImage(); Variable topVar = arguments[0]->getResult(); ImageObject* top = topVar.get<ImageObject>(); setLocalVariable("x", &x); setLocalVariable("y", &y); setLocalVariable("r1", &r1); setLocalVariable("g1", &g1); setLocalVariable("b1", &b1); setLocalVariable("h1", &h1); setLocalVariable("s1", &s1); setLocalVariable("v1", &v1); setLocalVariable("a1", &a1); setLocalVariable("r2", &r2); setLocalVariable("g2", &g2); setLocalVariable("b2", &b2); setLocalVariable("h2", &h2); setLocalVariable("s2", &s2); setLocalVariable("v2", &v2); setLocalVariable("a2", &a2); for (int cx = 0; cx < std::min(top->getWidth(),bottom->getWidth()); cx++) for (int cy = 0; cy < std::min(top->getHeight(), bottom->getHeight()); cy++) { x = cx; y = cy; if (store->mask->getValue(cx, cy) > 0) { Colour b = bottom->getPixel(cx, cy); r1 = (float)b.r(); g1 = (float)b.g(); b1 = (float)b.b(); h1 = (float)b.h(); s1 = (float)b.s(); v1 = (float)b.v(); a1 = (float)b.a(); Colour t = top->getPixel(cx, cy); r2 = (float)t.r(); g2 = (float)t.g(); b2 = (float)t.b(); h2 = (float)t.h(); s2 = (float)t.s(); v2 = (float)t.v(); a2 = (float)t.a(); Variable col = arguments[1]->getResult(); buffer->setPixel(cx, cy, *col.get<Colour>()); } } commitBuffer(); return Variable(); }
void SDLMouseCursor::load( ImageObject& img, const int& hotspotX, const int& hotspotY, const Color& transparentColor, const Color& invertColor ) { if ( imageIsSystemCursor( &img ) ) { Uint8* data = new Uint8[ (int)ceil( (double)(img.width() * img.height()) / 8 ) ]; Uint8* mask = new Uint8[ (int)ceil( (double)(img.width() * img.height()) / 8 ) ]; int bit = 1; int i = -1; Color black( 0, 0, 0 ); Color white( 255, 255, 255 ); //cout << "Cursor:" << endl; for( int y = 0; y < img.height(); y++ ) { for( int x = 0; x < img.width(); x++ ) { Color c = img.getPixel( x, y ); if ( bit == 128 ) { bit = 64; } else if ( bit == 64 ) bit = 32; else if ( bit == 32 ) bit = 16; else if ( bit == 16 ) bit = 8; else if ( bit == 8 ) bit = 4; else if ( bit == 4 ) bit = 2; else if ( bit == 2 ) bit = 1; else if ( bit == 1 ) { bit = 128; i++; data[i] = 0; mask[i] = 0; } if ( c == white ) { //cout << "."; mask[i] |= bit; } else if ( c == black ) { //cout << "X"; data[i] |= bit; mask[i] |= bit; } else if ( c == invertColor ) { //cout << "0"; data[i] |= bit; } else { //cout << " "; } } //cout << endl; } pCursor = SDL_CreateCursor( data, mask, img.width(), img.height(), hotspotX, hotspotY ); delete[] mask; delete[] data; } else { } }