SDLImage.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*
  2. * SDLImage.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "SDLImage.h"
  12. #include "SDLImageLoader.h"
  13. #include "SDL_Extensions.h"
  14. #include "../render/ColorFilter.h"
  15. #include "../render/Colors.h"
  16. #include "../render/CBitmapHandler.h"
  17. #include "../render/CDefFile.h"
  18. #include "../render/Graphics.h"
  19. #include "../xBRZ/xbrz.h"
  20. #include <tbb/parallel_for.h>
  21. #include <SDL_surface.h>
  22. #include <SDL_image.h>
  23. class SDLImageLoader;
  24. //First 8 colors in def palette used for transparency
  25. static constexpr std::array<SDL_Color, 8> sourcePalette = {{
  26. {0, 255, 255, SDL_ALPHA_OPAQUE},
  27. {255, 150, 255, SDL_ALPHA_OPAQUE},
  28. {255, 100, 255, SDL_ALPHA_OPAQUE},
  29. {255, 50, 255, SDL_ALPHA_OPAQUE},
  30. {255, 0, 255, SDL_ALPHA_OPAQUE},
  31. {255, 255, 0, SDL_ALPHA_OPAQUE},
  32. {180, 0, 255, SDL_ALPHA_OPAQUE},
  33. {0, 255, 0, SDL_ALPHA_OPAQUE}
  34. }};
  35. static constexpr std::array<ColorRGBA, 8> targetPalette = {{
  36. {0, 0, 0, 0 }, // 0 - transparency ( used in most images )
  37. {0, 0, 0, 64 }, // 1 - shadow border ( used in battle, adventure map def's )
  38. {0, 0, 0, 64 }, // 2 - shadow border ( used in fog-of-war def's )
  39. {0, 0, 0, 128}, // 3 - shadow body ( used in fog-of-war def's )
  40. {0, 0, 0, 128}, // 4 - shadow body ( used in battle, adventure map def's )
  41. {0, 0, 0, 0 }, // 5 - selection / owner flag ( used in battle, adventure map def's )
  42. {0, 0, 0, 128}, // 6 - shadow body below selection ( used in battle def's )
  43. {0, 0, 0, 64 } // 7 - shadow border below selection ( used in battle def's )
  44. }};
  45. static ui8 mixChannels(ui8 c1, ui8 c2, ui8 a1, ui8 a2)
  46. {
  47. return c1*a1 / 256 + c2*a2*(255 - a1) / 256 / 256;
  48. }
  49. static ColorRGBA addColors(const ColorRGBA & base, const ColorRGBA & over)
  50. {
  51. return ColorRGBA(
  52. mixChannels(over.r, base.r, over.a, base.a),
  53. mixChannels(over.g, base.g, over.a, base.a),
  54. mixChannels(over.b, base.b, over.a, base.a),
  55. static_cast<ui8>(over.a + base.a * (255 - over.a) / 256)
  56. );
  57. }
  58. static bool colorsSimilar (const SDL_Color & lhs, const SDL_Color & rhs)
  59. {
  60. // it seems that H3 does not requires exact match to replace colors -> (255, 103, 255) gets interpreted as shadow
  61. // exact logic is not clear and requires extensive testing with image editing
  62. // potential reason is that H3 uses 16-bit color format (565 RGB bits), meaning that 3 least significant bits are lost in red and blue component
  63. static const int threshold = 8;
  64. int diffR = static_cast<int>(lhs.r) - rhs.r;
  65. int diffG = static_cast<int>(lhs.g) - rhs.g;
  66. int diffB = static_cast<int>(lhs.b) - rhs.b;
  67. int diffA = static_cast<int>(lhs.a) - rhs.a;
  68. return std::abs(diffR) < threshold && std::abs(diffG) < threshold && std::abs(diffB) < threshold && std::abs(diffA) < threshold;
  69. }
  70. int IImage::width() const
  71. {
  72. return dimensions().x;
  73. }
  74. int IImage::height() const
  75. {
  76. return dimensions().y;
  77. }
  78. SDLImageShared::SDLImageShared(const CDefFile * data, size_t frame, size_t group, int preScaleFactor)
  79. : surf(nullptr),
  80. margins(0, 0),
  81. fullSize(0, 0),
  82. originalPalette(nullptr),
  83. preScaleFactor(preScaleFactor)
  84. {
  85. SDLImageLoader loader(this);
  86. data->loadFrame(frame, group, loader);
  87. savePalette();
  88. }
  89. SDLImageShared::SDLImageShared(SDL_Surface * from, int preScaleFactor)
  90. : surf(nullptr),
  91. margins(0, 0),
  92. fullSize(0, 0),
  93. originalPalette(nullptr),
  94. preScaleFactor(preScaleFactor)
  95. {
  96. surf = from;
  97. if (surf == nullptr)
  98. return;
  99. savePalette();
  100. surf->refcount++;
  101. fullSize.x = surf->w;
  102. fullSize.y = surf->h;
  103. }
  104. SDLImageShared::SDLImageShared(const ImagePath & filename, int preScaleFactor)
  105. : surf(nullptr),
  106. margins(0, 0),
  107. fullSize(0, 0),
  108. originalPalette(nullptr),
  109. preScaleFactor(preScaleFactor)
  110. {
  111. surf = BitmapHandler::loadBitmap(filename);
  112. if(surf == nullptr)
  113. {
  114. logGlobal->error("Error: failed to load image %s", filename.getOriginalName());
  115. return;
  116. }
  117. else
  118. {
  119. savePalette();
  120. fullSize.x = surf->w;
  121. fullSize.y = surf->h;
  122. optimizeSurface();
  123. }
  124. }
  125. void SDLImageShared::draw(SDL_Surface * where, SDL_Palette * palette, const Point & dest, const Rect * src, const ColorRGBA & colorMultiplier, uint8_t alpha, EImageBlitMode mode) const
  126. {
  127. if (!surf)
  128. return;
  129. Rect sourceRect(0, 0, surf->w, surf->h);
  130. Point destShift(0, 0);
  131. if(src)
  132. {
  133. if(src->x < margins.x)
  134. destShift.x += margins.x - src->x;
  135. if(src->y < margins.y)
  136. destShift.y += margins.y - src->y;
  137. sourceRect = Rect(*src).intersect(Rect(margins.x, margins.y, surf->w, surf->h));
  138. sourceRect -= margins;
  139. }
  140. else
  141. destShift = margins;
  142. destShift += dest;
  143. SDL_SetSurfaceColorMod(surf, colorMultiplier.r, colorMultiplier.g, colorMultiplier.b);
  144. SDL_SetSurfaceAlphaMod(surf, alpha);
  145. if (alpha != SDL_ALPHA_OPAQUE || (mode != EImageBlitMode::OPAQUE && surf->format->Amask != 0))
  146. SDL_SetSurfaceBlendMode(surf, SDL_BLENDMODE_BLEND);
  147. else
  148. SDL_SetSurfaceBlendMode(surf, SDL_BLENDMODE_NONE);
  149. if (palette && surf->format->palette)
  150. SDL_SetSurfacePalette(surf, palette);
  151. if(surf->format->palette && mode != EImageBlitMode::OPAQUE && mode != EImageBlitMode::COLORKEY)
  152. {
  153. CSDL_Ext::blit8bppAlphaTo24bpp(surf, sourceRect, where, destShift, alpha);
  154. }
  155. else
  156. {
  157. CSDL_Ext::blitSurface(surf, sourceRect, where, destShift);
  158. }
  159. if (surf->format->palette)
  160. SDL_SetSurfacePalette(surf, originalPalette);
  161. }
  162. void SDLImageShared::optimizeSurface()
  163. {
  164. if (!surf)
  165. return;
  166. int left = surf->w;
  167. int top = surf->h;
  168. int right = 0;
  169. int bottom = 0;
  170. // locate fully-transparent area around image
  171. // H3 hadles this on format level, but mods or images scaled in runtime do not
  172. if (surf->format->palette)
  173. {
  174. for (int y = 0; y < surf->h; ++y)
  175. {
  176. const uint8_t * row = static_cast<uint8_t *>(surf->pixels) + y * surf->pitch;
  177. for (int x = 0; x < surf->w; ++x)
  178. {
  179. if (row[x] != 0)
  180. {
  181. // opaque or can be opaque (e.g. disabled shadow)
  182. top = std::min(top, y);
  183. left = std::min(left, x);
  184. right = std::max(right, x);
  185. bottom = std::max(bottom, y);
  186. }
  187. }
  188. }
  189. }
  190. else
  191. {
  192. for (int y = 0; y < surf->h; ++y)
  193. {
  194. for (int x = 0; x < surf->w; ++x)
  195. {
  196. ColorRGBA color;
  197. SDL_GetRGBA(CSDL_Ext::getPixel(surf, x, y), surf->format, &color.r, &color.g, &color.b, &color.a);
  198. if (color.a != SDL_ALPHA_TRANSPARENT)
  199. {
  200. // opaque
  201. top = std::min(top, y);
  202. left = std::min(left, x);
  203. right = std::max(right, x);
  204. bottom = std::max(bottom, y);
  205. }
  206. }
  207. }
  208. }
  209. if (left == surf->w)
  210. {
  211. // empty image - simply delete it
  212. SDL_FreeSurface(surf);
  213. surf = nullptr;
  214. return;
  215. }
  216. if (left != 0 || top != 0 || right != surf->w - 1 || bottom != surf->h - 1)
  217. {
  218. // non-zero border found
  219. Rect newDimensions(left, top, right - left + 1, bottom - top + 1);
  220. SDL_Rect rectSDL = CSDL_Ext::toSDL(newDimensions);
  221. auto newSurface = CSDL_Ext::newSurface(newDimensions.dimensions(), surf);
  222. SDL_SetSurfaceBlendMode(surf, SDL_BLENDMODE_NONE);
  223. SDL_BlitSurface(surf, &rectSDL, newSurface, nullptr);
  224. if (SDL_HasColorKey(surf))
  225. {
  226. uint32_t colorKey;
  227. SDL_GetColorKey(surf, &colorKey);
  228. SDL_SetColorKey(newSurface, SDL_TRUE, colorKey);
  229. }
  230. SDL_FreeSurface(surf);
  231. surf = newSurface;
  232. margins.x += left;
  233. margins.y += top;
  234. }
  235. }
  236. std::shared_ptr<const ISharedImage> SDLImageShared::scaleInteger(int factor, SDL_Palette * palette) const
  237. {
  238. if (factor <= 0)
  239. throw std::runtime_error("Unable to scale by integer value of " + std::to_string(factor));
  240. if (palette && surf && surf->format->palette)
  241. SDL_SetSurfacePalette(surf, palette);
  242. SDL_Surface * scaled = nullptr;
  243. if(preScaleFactor == factor)
  244. return shared_from_this();
  245. else if(preScaleFactor == 1)
  246. scaled = CSDL_Ext::scaleSurfaceIntegerFactor(surf, factor, EScalingAlgorithm::XBRZ);
  247. else
  248. scaled = CSDL_Ext::scaleSurface(surf, (surf->w / preScaleFactor) * factor, (surf->h / preScaleFactor) * factor);
  249. auto ret = std::make_shared<SDLImageShared>(scaled, preScaleFactor);
  250. ret->fullSize.x = fullSize.x * factor;
  251. ret->fullSize.y = fullSize.y * factor;
  252. ret->margins.x = margins.x * factor;
  253. ret->margins.y = margins.y * factor;
  254. ret->optimizeSurface();
  255. // erase our own reference
  256. SDL_FreeSurface(scaled);
  257. if (surf && surf->format->palette)
  258. SDL_SetSurfacePalette(surf, originalPalette);
  259. return ret;
  260. }
  261. std::shared_ptr<const ISharedImage> SDLImageShared::scaleTo(const Point & size, SDL_Palette * palette) const
  262. {
  263. float scaleX = float(size.x) / fullSize.x;
  264. float scaleY = float(size.y) / fullSize.y;
  265. if (palette && surf->format->palette)
  266. SDL_SetSurfacePalette(surf, palette);
  267. auto scaled = CSDL_Ext::scaleSurface(surf, (int)(surf->w * scaleX), (int)(surf->h * scaleY));
  268. if (scaled->format && scaled->format->palette) // fix color keying, because SDL loses it at this point
  269. CSDL_Ext::setColorKey(scaled, scaled->format->palette->colors[0]);
  270. else if(scaled->format && scaled->format->Amask)
  271. SDL_SetSurfaceBlendMode(scaled, SDL_BLENDMODE_BLEND);//just in case
  272. else
  273. CSDL_Ext::setDefaultColorKey(scaled);//just in case
  274. auto ret = std::make_shared<SDLImageShared>(scaled, preScaleFactor);
  275. ret->fullSize.x = (int) round((float)fullSize.x * scaleX);
  276. ret->fullSize.y = (int) round((float)fullSize.y * scaleY);
  277. ret->margins.x = (int) round((float)margins.x * scaleX);
  278. ret->margins.y = (int) round((float)margins.y * scaleY);
  279. // erase our own reference
  280. SDL_FreeSurface(scaled);
  281. if (surf->format->palette)
  282. SDL_SetSurfacePalette(surf, originalPalette);
  283. return ret;
  284. }
  285. void SDLImageShared::exportBitmap(const boost::filesystem::path& path, SDL_Palette * palette) const
  286. {
  287. if (!surf)
  288. return;
  289. if (palette && surf->format->palette)
  290. SDL_SetSurfacePalette(surf, palette);
  291. IMG_SavePNG(surf, path.string().c_str());
  292. if (palette && surf->format->palette)
  293. SDL_SetSurfacePalette(surf, originalPalette);
  294. }
  295. void SDLImageIndexed::playerColored(PlayerColor player)
  296. {
  297. graphics->setPlayerPalette(currentPalette, player);
  298. }
  299. bool SDLImageShared::isTransparent(const Point & coords) const
  300. {
  301. if (surf)
  302. return CSDL_Ext::isTransparent(surf, coords.x - margins.x, coords.y - margins.y);
  303. else
  304. return true;
  305. }
  306. Point SDLImageShared::dimensions() const
  307. {
  308. return fullSize / preScaleFactor;
  309. }
  310. std::shared_ptr<IImage> SDLImageShared::createImageReference(EImageBlitMode mode) const
  311. {
  312. if (surf && surf->format->palette)
  313. return std::make_shared<SDLImageIndexed>(shared_from_this(), originalPalette, mode);
  314. else
  315. return std::make_shared<SDLImageRGB>(shared_from_this(), mode);
  316. }
  317. std::shared_ptr<const ISharedImage> SDLImageShared::horizontalFlip() const
  318. {
  319. SDL_Surface * flipped = CSDL_Ext::horizontalFlip(surf);
  320. auto ret = std::make_shared<SDLImageShared>(flipped, preScaleFactor);
  321. ret->fullSize = fullSize;
  322. ret->margins.x = margins.x;
  323. ret->margins.y = fullSize.y - surf->h - margins.y;
  324. ret->fullSize = fullSize;
  325. return ret;
  326. }
  327. std::shared_ptr<const ISharedImage> SDLImageShared::verticalFlip() const
  328. {
  329. SDL_Surface * flipped = CSDL_Ext::verticalFlip(surf);
  330. auto ret = std::make_shared<SDLImageShared>(flipped, preScaleFactor);
  331. ret->fullSize = fullSize;
  332. ret->margins.x = fullSize.x - surf->w - margins.x;
  333. ret->margins.y = margins.y;
  334. ret->fullSize = fullSize;
  335. return ret;
  336. }
  337. // Keep the original palette, in order to do color switching operation
  338. void SDLImageShared::savePalette()
  339. {
  340. // For some images that don't have palette, skip this
  341. if(surf->format->palette == nullptr)
  342. return;
  343. if(originalPalette == nullptr)
  344. originalPalette = SDL_AllocPalette(surf->format->palette->ncolors);
  345. SDL_SetPaletteColors(originalPalette, surf->format->palette->colors, 0, surf->format->palette->ncolors);
  346. }
  347. void SDLImageIndexed::shiftPalette(uint32_t firstColorID, uint32_t colorsToMove, uint32_t distanceToMove)
  348. {
  349. std::vector<SDL_Color> shifterColors(colorsToMove);
  350. for(uint32_t i=0; i<colorsToMove; ++i)
  351. shifterColors[(i+distanceToMove)%colorsToMove] = originalPalette->colors[firstColorID + i];
  352. SDL_SetPaletteColors(currentPalette, shifterColors.data(), firstColorID, colorsToMove);
  353. }
  354. void SDLImageIndexed::adjustPalette(const ColorFilter & shifter, uint32_t colorsToSkipMask)
  355. {
  356. // If shadow is enabled, following colors must be skipped unconditionally
  357. if (blitMode == EImageBlitMode::WITH_SHADOW || blitMode == EImageBlitMode::WITH_SHADOW_AND_OVERLAY)
  358. colorsToSkipMask |= (1 << 0) + (1 << 1) + (1 << 4);
  359. // Note: here we skip first colors in the palette that are predefined in H3 images
  360. for(int i = 0; i < currentPalette->ncolors; i++)
  361. {
  362. if (i < std::size(sourcePalette) && colorsSimilar(sourcePalette[i], originalPalette->colors[i]))
  363. continue;
  364. if(i < std::numeric_limits<uint32_t>::digits && ((colorsToSkipMask >> i) & 1) == 1)
  365. continue;
  366. currentPalette->colors[i] = CSDL_Ext::toSDL(shifter.shiftColor(CSDL_Ext::fromSDL(originalPalette->colors[i])));
  367. }
  368. }
  369. SDLImageIndexed::SDLImageIndexed(const std::shared_ptr<const ISharedImage> & image, SDL_Palette * originalPalette, EImageBlitMode mode)
  370. :SDLImageBase::SDLImageBase(image, mode)
  371. ,originalPalette(originalPalette)
  372. {
  373. currentPalette = SDL_AllocPalette(originalPalette->ncolors);
  374. SDL_SetPaletteColors(currentPalette, originalPalette->colors, 0, originalPalette->ncolors);
  375. preparePalette();
  376. }
  377. SDLImageIndexed::~SDLImageIndexed()
  378. {
  379. SDL_FreePalette(currentPalette);
  380. }
  381. void SDLImageIndexed::setShadowTransparency(float factor)
  382. {
  383. ColorRGBA shadow50(0, 0, 0, 128 * factor);
  384. ColorRGBA shadow25(0, 0, 0, 64 * factor);
  385. std::array<SDL_Color, 5> colorsSDL = {
  386. originalPalette->colors[0],
  387. originalPalette->colors[1],
  388. originalPalette->colors[2],
  389. originalPalette->colors[3],
  390. originalPalette->colors[4]
  391. };
  392. // seems to be used unconditionally
  393. colorsSDL[0] = CSDL_Ext::toSDL(Colors::TRANSPARENCY);
  394. colorsSDL[1] = CSDL_Ext::toSDL(shadow25);
  395. colorsSDL[4] = CSDL_Ext::toSDL(shadow50);
  396. // seems to be used only if color matches
  397. if (colorsSimilar(originalPalette->colors[2], sourcePalette[2]))
  398. colorsSDL[2] = CSDL_Ext::toSDL(shadow25);
  399. if (colorsSimilar(originalPalette->colors[3], sourcePalette[3]))
  400. colorsSDL[3] = CSDL_Ext::toSDL(shadow50);
  401. SDL_SetPaletteColors(currentPalette, colorsSDL.data(), 0, colorsSDL.size());
  402. }
  403. void SDLImageIndexed::setOverlayColor(const ColorRGBA & color)
  404. {
  405. currentPalette->colors[5] = CSDL_Ext::toSDL(addColors(targetPalette[5], color));
  406. for (int i : {6,7})
  407. {
  408. if (colorsSimilar(originalPalette->colors[i], sourcePalette[i]))
  409. currentPalette->colors[i] = CSDL_Ext::toSDL(addColors(targetPalette[i], color));
  410. }
  411. }
  412. void SDLImageIndexed::preparePalette()
  413. {
  414. switch(blitMode)
  415. {
  416. case EImageBlitMode::ONLY_SHADOW:
  417. case EImageBlitMode::ONLY_OVERLAY:
  418. adjustPalette(ColorFilter::genAlphaShifter(0), 0);
  419. break;
  420. }
  421. switch(blitMode)
  422. {
  423. case EImageBlitMode::SIMPLE:
  424. case EImageBlitMode::WITH_SHADOW:
  425. case EImageBlitMode::ONLY_SHADOW:
  426. case EImageBlitMode::WITH_SHADOW_AND_OVERLAY:
  427. setShadowTransparency(1.0);
  428. break;
  429. case EImageBlitMode::ONLY_BODY:
  430. case EImageBlitMode::ONLY_BODY_IGNORE_OVERLAY:
  431. case EImageBlitMode::ONLY_OVERLAY:
  432. setShadowTransparency(0.0);
  433. break;
  434. }
  435. switch(blitMode)
  436. {
  437. case EImageBlitMode::ONLY_OVERLAY:
  438. case EImageBlitMode::WITH_SHADOW_AND_OVERLAY:
  439. setOverlayColor(Colors::WHITE_TRUE);
  440. break;
  441. case EImageBlitMode::ONLY_SHADOW:
  442. case EImageBlitMode::ONLY_BODY:
  443. setOverlayColor(Colors::TRANSPARENCY);
  444. break;
  445. }
  446. }
  447. SDLImageShared::~SDLImageShared()
  448. {
  449. SDL_FreeSurface(surf);
  450. SDL_FreePalette(originalPalette);
  451. }
  452. SDLImageBase::SDLImageBase(const std::shared_ptr<const ISharedImage> & image, EImageBlitMode mode)
  453. :image(image)
  454. , alphaValue(SDL_ALPHA_OPAQUE)
  455. , blitMode(mode)
  456. {}
  457. std::shared_ptr<const ISharedImage> SDLImageBase::getSharedImage() const
  458. {
  459. return image;
  460. }
  461. void SDLImageRGB::draw(SDL_Surface * where, const Point & pos, const Rect * src) const
  462. {
  463. image->draw(where, nullptr, pos, src, Colors::WHITE_TRUE, alphaValue, blitMode);
  464. }
  465. void SDLImageIndexed::draw(SDL_Surface * where, const Point & pos, const Rect * src) const
  466. {
  467. image->draw(where, currentPalette, pos, src, Colors::WHITE_TRUE, alphaValue, blitMode);
  468. }
  469. void SDLImageIndexed::exportBitmap(const boost::filesystem::path & path) const
  470. {
  471. image->exportBitmap(path, currentPalette);
  472. }
  473. void SDLImageIndexed::scaleTo(const Point & size)
  474. {
  475. image = image->scaleTo(size, currentPalette);
  476. }
  477. void SDLImageRGB::scaleTo(const Point & size)
  478. {
  479. image = image->scaleTo(size, nullptr);
  480. }
  481. void SDLImageIndexed::scaleInteger(int factor)
  482. {
  483. image = image->scaleInteger(factor, currentPalette);
  484. }
  485. void SDLImageRGB::scaleInteger(int factor)
  486. {
  487. image = image->scaleInteger(factor, nullptr);
  488. }
  489. void SDLImageRGB::exportBitmap(const boost::filesystem::path & path) const
  490. {
  491. image->exportBitmap(path, nullptr);
  492. }
  493. bool SDLImageBase::isTransparent(const Point & coords) const
  494. {
  495. return image->isTransparent(coords);
  496. }
  497. Point SDLImageBase::dimensions() const
  498. {
  499. return image->dimensions();
  500. }
  501. void SDLImageBase::setAlpha(uint8_t value)
  502. {
  503. alphaValue = value;
  504. }
  505. void SDLImageBase::setBlitMode(EImageBlitMode mode)
  506. {
  507. blitMode = mode;
  508. }
  509. void SDLImageRGB::setOverlayColor(const ColorRGBA & color)
  510. {}
  511. void SDLImageRGB::playerColored(PlayerColor player)
  512. {}
  513. void SDLImageRGB::shiftPalette(uint32_t firstColorID, uint32_t colorsToMove, uint32_t distanceToMove)
  514. {}
  515. void SDLImageRGB::adjustPalette(const ColorFilter & shifter, uint32_t colorsToSkipMask)
  516. {}