示例#1
0
Window::Window(int x, int y, int w, int h, const std::wstring &bg,
               bool frameWidth, bool raised)
{
    left = x;
    top = y;
    width = w;
    height = h;

    SDL_Surface *s = screen.getSurface();
    SDL_Surface *win = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
                                            s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask,
                                            s->format->Bmask, s->format->Amask);

    SDL_Surface *tile = loadImage(bg);
    SDL_Rect src = { 0, 0, tile->w, tile->h };
    SDL_Rect dst = { 0, 0, tile->w, tile->h };
    for (int j = 0; j < height; j += tile->h)
        for (int i = 0; i < width; i += tile->w) {
            dst.x = i;
            dst.y = j;
            SDL_BlitSurface(tile, &src, win, &dst);
        }
    SDL_FreeSurface(tile);

    SDL_LockSurface(win);
    double k = 2.6;
    double f = 0.1;
    for (int i = 0; i < frameWidth; i++) {
        double ltK, rbK;
        if (raised) {
            ltK = k;
            rbK = f;
        } else {
            ltK = f;
            rbK = k;
        }
        for (int j = i; j < height - i - 1; j++)
            adjustBrightness(win, i, j, ltK);
        for (int j = i; j < width - i; j++)
            adjustBrightness(win, j, i, ltK);
        for (int j = i+1; j < height - i; j++)
            adjustBrightness(win, width - i - 1, j, rbK);
        for (int j = i; j < width - i - 1; j++)
            adjustBrightness(win, j, height - i - 1, rbK);
        k -= 0.2;
        f += 0.1;
    }
    SDL_UnlockSurface(win);

    background = SDL_DisplayFormat(win);
    SDL_FreeSurface(win);
}
示例#2
0
void Slider::createSlider(int size)
{
    SDL_Surface *s = screen.getSurface();
    SDL_Surface *image = SDL_CreateRGBSurface(SDL_SWSURFACE, size, size,
                         s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask,
                         s->format->Bmask, s->format->Amask);

    SDL_Surface *tile = loadImage(L"blue.bmp");
    SDL_Rect src = { 0, 0, tile->w, tile->h };
    SDL_Rect dst = { 0, 0, tile->w, tile->h };
    for (int j = 0; j < size; j += tile->h)
        for (int i = 0; i < size; i += tile->w) {
            dst.x = i;
            dst.y = j;
            SDL_BlitSurface(tile, &src, image, &dst);
        }
    SDL_FreeSurface(tile);

    SDL_LockSurface(image);
    drawBevel(image, 0, 0, size, size, false, 1);
    drawBevel(image, 1, 1, size - 2, size - 2, true, 1);
    SDL_UnlockSurface(image);

    activeSlider = adjustBrightness(image, 1.5, false);
    slider = SDL_DisplayFormat(image);

    SDL_FreeSurface(image);
}
示例#3
0
Button::Button(int x, int y, int w, int h, Font *font, int r, int g, int b,
        const std::wstring &bg, const std::wstring &text, Command *cmd):
            left(x), top(y), width(w), height(h), mouseInside(false), command(cmd)
{
    SDL_Surface *s = screen.getSurface();
    image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 
            s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask,
            s->format->Bmask, s->format->Amask);

    SDL_Surface *tile = loadImage(bg);
    SDL_Rect src = { 0, 0, tile->w, tile->h };
    SDL_Rect dst = { 0, 0, tile->w, tile->h };
    for (int j = 0; j < height; j += tile->h)
        for (int i = 0; i < width; i += tile->w) {
            dst.x = i;
            dst.y = j;
            SDL_BlitSurface(tile, &src, image, &dst);
        }
    SDL_FreeSurface(tile);

    SDL_LockSurface(image);
    drawBevel(image, 0, 0, width, height, false, 1);
    drawBevel(image, 1, 1, width - 2, height - 2, true, 1);
    SDL_UnlockSurface(image);
    
    int tW, tH;
    font->getSize(text, tW, tH);
    font->draw(image, (width - tW) / 2, (height - tH) / 2, r, g, b, true, text);
    
    highlighted = adjustBrightness(image, 1.5, false);
}
示例#4
0
Button::Button(int x, int y, const std::wstring &name, Command *cmd, 
        bool transparent): left(x), top(y), image(loadImage(name, transparent)),
            mouseInside(false), command(cmd)
{
    highlighted = adjustBrightness(image, 1.5, transparent);
    width = image->w;
    height = image->h;
}
示例#5
0
Checkbox::Checkbox(int x, int y, int w, int h, Font *font,
                   int r, int g, int b, const std::wstring &bg,
                   bool &chk): checked(chk)
{
    left = x;
    top = y;
    width = w;
    height = h;
    checked = chk;

    SDL_Surface *s = screen.getSurface();
    image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
                                 s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask,
                                 s->format->Bmask, s->format->Amask);

    SDL_Surface *tile = loadImage(bg);
    SDL_Rect src = { 0, 0, tile->w, tile->h };
    SDL_Rect dst = { 0, 0, tile->w, tile->h };
    for (int j = 0; j < height; j += tile->h)
        for (int i = 0; i < width; i += tile->w) {
            dst.x = i;
            dst.y = j;
            SDL_BlitSurface(tile, &src, image, &dst);
        }
    SDL_FreeSurface(tile);

    SDL_LockSurface(image);
    drawBevel(image, 0, 0, width, height, false, 1);
    drawBevel(image, 1, 1, width - 2, height - 2, true, 1);
    SDL_UnlockSurface(image);

    highlighted = adjustBrightness(image, 1.5, false);

    checkedImage = SDL_DisplayFormat(image);
    int tW, tH;
    font->getSize(L"X", tW, tH);
    tH += 2;
    tW += 2;
    font->draw(checkedImage, (width - tW) / 2, (height - tH) / 2, r, g, b,
               true, L"X");
    checkedHighlighted = adjustBrightness(checkedImage, 1.5, false);

    mouseInside = false;
}
示例#6
0
Button::Button(int x, int y, const std::wstring &name, Command *cmd,
               bool transparent)
{
    image = loadImage(name, transparent);
    highlighted = adjustBrightness(image, 1.5, transparent);

    left = x;
    top = y;
    width = image->w;
    height = image->h;

    mouseInside = false;
    command = cmd;
}
示例#7
0
IconSet::IconSet()
{
    std::wstring buf = L"xy.bmp";
    
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 6; j++) {
            buf[1] = L'1' + j;
            buf[0] = L'a' + i;
            smallIcons[i][j][0] = loadImage(buf);
            smallIcons[i][j][1] = adjustBrightness(smallIcons[i][j][0], 1.5, false);
            buf[0] = L'A' + i;
            largeIcons[i][j][0] = loadImage(buf);
            largeIcons[i][j][1] = adjustBrightness(largeIcons[i][j][0], 1.5, false);
        }
    emptyFieldIcon = loadImage(L"tile.bmp");
    emptyHintIcon = loadImage(L"hint-tile.bmp");
    nearHintIcon[0] = loadImage(L"hint-near.bmp");
    nearHintIcon[1] = adjustBrightness(nearHintIcon[0], 1.5, false);
    sideHintIcon[0] = loadImage(L"hint-side.bmp");
    sideHintIcon[1] = adjustBrightness(sideHintIcon[0], 1.5, false);
    betweenArrow[0] = loadImage(L"betwarr.bmp", true);
    betweenArrow[1] = adjustBrightness(betweenArrow[0], 1.5, false);
}
示例#8
0
Button::Button(int x, int y, int w, int h, Font *font,
               int r, int g, int b, const std::wstring &bg,
               const std::wstring &text, bool bevel, Command *cmd)
{
    left = x;
    top = y;
    width = w;
    height = h;

    SDL_Surface *s = screen.getSurface();
    image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
                                 s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask,
                                 s->format->Bmask, s->format->Amask);

    SDL_Surface *tile = loadImage(bg, true);
    SDL_Rect src = { 0, 0, tile->w, tile->h };
    SDL_Rect dst = { 0, 0, tile->w, tile->h };
    for (int j = 0; j < height; j += tile->h)
        for (int i = 0; i < width; i += tile->w) {
            dst.x = i;
            dst.y = j;
            SDL_BlitSurface(tile, &src, image, &dst);
        }
    SDL_FreeSurface(tile);

    if (bevel) {
        SDL_LockSurface(image);
        drawBevel(image, 0, 0, width, height, false, 1);
        drawBevel(image, 1, 1, width - 2, height - 2, true, 1);
        SDL_UnlockSurface(image);
    }

    int tW, tH;
    font->getSize(text, tW, tH);
    font->draw(image, (width - tW) / 2, (height - tH) / 2, r, g, b, true, text);

    highlighted = adjustBrightness(image, 1.5, false);
    SDL_SetColorKey(image, SDL_SRCCOLORKEY, getCornerPixel(image));
    SDL_SetColorKey(highlighted, SDL_SRCCOLORKEY, getCornerPixel(highlighted));

    mouseInside = false;
    command = cmd;
}
示例#9
0
void adjustBrightnessGrayscale(QImage& rgb_image, QImage const& brightness)
{
	adjustBrightness(rgb_image, brightness, 11.0/32.0, 5.0/32.0);
}