Image *SurfaceImageHelper::_SDLload(SDL_Surface *tmpImage) const { if (!tmpImage) return nullptr; SDL_Surface *image = convertTo32Bit(tmpImage); return new Image(image, false, nullptr); }
Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye) { SDL_Surface *const tmpImage = loadPng(rw); if (!tmpImage) { reportAlways("Error, image load failed: %s", IMG_GetError()); return nullptr; } SDL_Surface *const surf = convertTo32Bit(tmpImage); MSDL_FreeSurface(tmpImage); if (!surf) return nullptr; uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); const int type = dye.getType(); switch (type) { case 1: { const DyePalette *const pal = dye.getSPalete(); if (pal) pal->replaceSOGLColor(pixels, surf->w * surf->h); break; } case 2: { const DyePalette *const pal = dye.getAPalete(); if (pal) pal->replaceAOGLColor(pixels, surf->w * surf->h); break; } case 0: default: { dye.normalOGLDye(pixels, surf->w * surf->h); break; } } Image *const image = loadSurface(surf); MSDL_FreeSurface(surf); return image; }
void ImageWindow::createActions() { openAction = new QAction(tr("&Open..."), this); openAction->setShortcut(tr("Ctrl+O")); openAction->setStatusTip(tr("Open an existing image file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); saveAction = new QAction(tr("&Save"), this); saveAction->setShortcut(tr("Ctrl+S")); saveAction->setStatusTip(tr("Save the image to disk")); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); saveAsAction = new QAction(tr("Save &As..."), this); saveAsAction->setStatusTip(tr("Save the image under a new name")); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); exitAction = new QAction(tr("E&xit"), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); flipHorizontallyAction = new QAction(tr("Flip &Horizontally"), this); flipHorizontallyAction->setShortcut(tr("Ctrl+H")); flipHorizontallyAction->setStatusTip(tr("Flip the image " "horizontally")); connect(flipHorizontallyAction, SIGNAL(triggered()), this, SLOT(flipHorizontally())); flipVerticallyAction = new QAction(tr("Flip &Vertically"), this); flipVerticallyAction->setShortcut(tr("Ctrl+V")); flipVerticallyAction->setStatusTip(tr("Flip the image vertically")); connect(flipVerticallyAction, SIGNAL(triggered()), this, SLOT(flipVertically())); resizeAction = new QAction(tr("&Resize..."), this); resizeAction->setShortcut(tr("Ctrl+R")); resizeAction->setStatusTip(tr("Resize the image")); connect(resizeAction, SIGNAL(triggered()), this, SLOT(resizeImage())); convertTo32BitAction = new QAction(tr("32 Bit"), this); convertTo32BitAction->setStatusTip(tr("Convert to 32-bit image")); connect(convertTo32BitAction, SIGNAL(triggered()), this, SLOT(convertTo32Bit())); convertTo8BitAction = new QAction(tr("8 Bit"), this); convertTo8BitAction->setStatusTip(tr("Convert to 8-bit image")); connect(convertTo8BitAction, SIGNAL(triggered()), this, SLOT(convertTo8Bit())); convertTo1BitAction = new QAction(tr("1 Bit"), this); convertTo1BitAction->setStatusTip(tr("Convert to 1-bit image")); connect(convertTo1BitAction, SIGNAL(triggered()), this, SLOT(convertTo1Bit())); aboutAction = new QAction(tr("&About"), this); aboutAction->setStatusTip(tr("Show the application's About box")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); }