mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-27 02:50:32 +00:00
0b923489dd
byuu says: New update. Most of the work today went into eliminating hiro::Image from all objects in all ports, replacing with nall::image. That took an eternity. Changelog: - fixed crashing bug when loading games [thanks endrift!!] - toggling "show status bar" option adjusts window geometry (not supposed to recenter the window, though) - button sizes improved; icon-only button icons no longer being cut off
29 lines
737 B
C++
29 lines
737 B
C++
#pragma once
|
|
|
|
namespace nall {
|
|
|
|
auto image::bitDepth(uint64_t color) -> unsigned {
|
|
unsigned depth = 0;
|
|
if(color) while((color & 1) == 0) color >>= 1;
|
|
while((color & 1) == 1) { color >>= 1; depth++; }
|
|
return depth;
|
|
}
|
|
|
|
auto image::bitShift(uint64_t color) -> unsigned {
|
|
unsigned shift = 0;
|
|
if(color) while((color & 1) == 0) { color >>= 1; shift++; }
|
|
return shift;
|
|
}
|
|
|
|
auto image::normalize(uint64_t color, unsigned sourceDepth, unsigned targetDepth) -> uint64_t {
|
|
if(sourceDepth == 0 || targetDepth == 0) return 0;
|
|
while(sourceDepth < targetDepth) {
|
|
color = (color << sourceDepth) | color;
|
|
sourceDepth += sourceDepth;
|
|
}
|
|
if(targetDepth < sourceDepth) color >>= (sourceDepth - targetDepth);
|
|
return color;
|
|
}
|
|
|
|
}
|