2016-01-07 17:14:33 +09:00
|
|
|
#pragma once
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 12:22:54 +09:00
|
|
|
|
2014-01-13 18:35:46 +09:00
|
|
|
#include <algorithm>
|
|
|
|
|
2018-10-04 19:11:23 +09:00
|
|
|
#include <nall/file-map.hpp>
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 12:22:54 +09:00
|
|
|
#include <nall/interpolation.hpp>
|
|
|
|
#include <nall/stdint.hpp>
|
2015-08-02 15:23:13 +09:00
|
|
|
#include <nall/decode/bmp.hpp>
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 19:10:46 +09:00
|
|
|
#include <nall/decode/png.hpp>
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
struct image {
|
2021-02-08 18:11:00 +09:00
|
|
|
enum class blend : u32 {
|
2018-08-04 20:44:00 +09:00
|
|
|
add,
|
|
|
|
sourceAlpha, //color = sourceColor * sourceAlpha + targetColor * (1 - sourceAlpha)
|
|
|
|
sourceColor, //color = sourceColor
|
|
|
|
targetAlpha, //color = targetColor * targetAlpha + sourceColor * (1 - targetAlpha)
|
|
|
|
targetColor, //color = targetColor
|
|
|
|
};
|
|
|
|
|
|
|
|
struct channel {
|
2021-02-08 18:11:00 +09:00
|
|
|
channel(u64 mask, u32 depth, u32 shift) : _mask(mask), _depth(depth), _shift(shift) {
|
2018-08-04 20:44:00 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
auto operator==(const channel& source) const -> bool {
|
|
|
|
return _mask == source._mask && _depth == source._depth && _shift == source._shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto operator!=(const channel& source) const -> bool {
|
|
|
|
return !operator==(source);
|
|
|
|
}
|
|
|
|
|
2020-04-04 13:14:00 +09:00
|
|
|
auto mask() const { return _mask; }
|
|
|
|
auto depth() const { return _depth; }
|
|
|
|
auto shift() const { return _shift; }
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
private:
|
2021-02-08 18:11:00 +09:00
|
|
|
u64 _mask;
|
|
|
|
u32 _depth;
|
|
|
|
u32 _shift;
|
2018-08-04 20:44:00 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
//core.hpp
|
2020-04-05 10:19:00 +09:00
|
|
|
image(const image& source);
|
|
|
|
image(image&& source);
|
2021-02-08 18:11:00 +09:00
|
|
|
image(bool endian, u32 depth, u64 alphaMask, u64 redMask, u64 greenMask, u64 blueMask);
|
2020-04-05 10:19:00 +09:00
|
|
|
image(const string& filename);
|
2021-02-08 18:11:00 +09:00
|
|
|
image(const void* data, u32 size);
|
|
|
|
image(const vector<u8>& buffer);
|
|
|
|
template<u32 Size> image(const u8 (&Name)[Size]);
|
2020-04-05 10:19:00 +09:00
|
|
|
image();
|
|
|
|
~image();
|
|
|
|
|
|
|
|
auto operator=(const image& source) -> image&;
|
|
|
|
auto operator=(image&& source) -> image&;
|
|
|
|
|
|
|
|
explicit operator bool() const;
|
|
|
|
auto operator==(const image& source) const -> bool;
|
|
|
|
auto operator!=(const image& source) const -> bool;
|
|
|
|
|
2021-02-08 18:11:00 +09:00
|
|
|
auto read(const u8* data) const -> u64;
|
|
|
|
auto write(u8* data, u64 value) const -> void;
|
2020-04-05 10:19:00 +09:00
|
|
|
|
|
|
|
auto free() -> void;
|
|
|
|
auto load(const string& filename) -> bool;
|
2021-02-08 18:11:00 +09:00
|
|
|
auto copy(const void* data, u32 pitch, u32 width, u32 height) -> void;
|
|
|
|
auto allocate(u32 width, u32 height) -> void;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//fill.hpp
|
2021-02-08 18:11:00 +09:00
|
|
|
auto fill(u64 color = 0) -> void;
|
|
|
|
auto gradient(u64 a, u64 b, u64 c, u64 d) -> void;
|
|
|
|
auto gradient(u64 a, u64 b, s32 radiusX, s32 radiusY, s32 centerX, s32 centerY, function<f64 (f64, f64)> callback) -> void;
|
|
|
|
auto crossGradient(u64 a, u64 b, s32 radiusX, s32 radiusY, s32 centerX, s32 centerY) -> void;
|
|
|
|
auto diamondGradient(u64 a, u64 b, s32 radiusX, s32 radiusY, s32 centerX, s32 centerY) -> void;
|
|
|
|
auto horizontalGradient(u64 a, u64 b, s32 radiusX, s32 radiusY, s32 centerX, s32 centerY) -> void;
|
|
|
|
auto radialGradient(u64 a, u64 b, s32 radiusX, s32 radiusY, s32 centerX, s32 centerY) -> void;
|
|
|
|
auto sphericalGradient(u64 a, u64 b, s32 radiusX, s32 radiusY, s32 centerX, s32 centerY) -> void;
|
|
|
|
auto squareGradient(u64 a, u64 b, s32 radiusX, s32 radiusY, s32 centerX, s32 centerY) -> void;
|
|
|
|
auto verticalGradient(u64 a, u64 b, s32 radiusX, s32 radiusY, s32 centerX, s32 centerY) -> void;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//scale.hpp
|
2021-02-08 18:11:00 +09:00
|
|
|
auto scale(u32 width, u32 height, bool linear = true) -> void;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//blend.hpp
|
2021-02-08 18:11:00 +09:00
|
|
|
auto impose(blend mode, u32 targetX, u32 targetY, image source, u32 x, u32 y, u32 width, u32 height) -> void;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//utility.hpp
|
2021-02-08 18:11:00 +09:00
|
|
|
auto shrink(u64 transparentColor = 0) -> void;
|
|
|
|
auto crop(u32 x, u32 y, u32 width, u32 height) -> bool;
|
|
|
|
auto alphaBlend(u64 alphaColor) -> void;
|
2020-04-05 10:19:00 +09:00
|
|
|
auto alphaMultiply() -> void;
|
|
|
|
auto transform(const image& source = {}) -> void;
|
2021-02-08 18:11:00 +09:00
|
|
|
auto transform(bool endian, u32 depth, u64 alphaMask, u64 redMask, u64 greenMask, u64 blueMask) -> void;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//static.hpp
|
2021-02-08 18:11:00 +09:00
|
|
|
static auto bitDepth(u64 color) -> u32;
|
|
|
|
static auto bitShift(u64 color) -> u32;
|
|
|
|
static auto normalize(u64 color, u32 sourceDepth, u32 targetDepth) -> u64;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//access
|
2020-04-04 13:14:00 +09:00
|
|
|
auto data() { return _data; }
|
|
|
|
auto data() const { return _data; }
|
|
|
|
auto width() const { return _width; }
|
|
|
|
auto height() const { return _height; }
|
|
|
|
|
|
|
|
auto endian() const { return _endian; }
|
|
|
|
auto depth() const { return _depth; }
|
|
|
|
auto stride() const { return (_depth + 7) >> 3; }
|
|
|
|
|
|
|
|
auto pitch() const { return _width * stride(); }
|
|
|
|
auto size() const { return _height * pitch(); }
|
|
|
|
|
|
|
|
auto alpha() const { return _alpha; }
|
|
|
|
auto red() const { return _red; }
|
|
|
|
auto green() const { return _green; }
|
|
|
|
auto blue() const { return _blue; }
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
private:
|
|
|
|
//core.hpp
|
2021-02-08 18:11:00 +09:00
|
|
|
auto allocate(u32 width, u32 height, u32 stride) -> u8*;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//scale.hpp
|
2021-02-08 18:11:00 +09:00
|
|
|
auto scaleLinearWidth(u32 width) -> void;
|
|
|
|
auto scaleLinearHeight(u32 height) -> void;
|
|
|
|
auto scaleLinear(u32 width, u32 height) -> void;
|
|
|
|
auto scaleNearest(u32 width, u32 height) -> void;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//load.hpp
|
2020-04-05 10:19:00 +09:00
|
|
|
auto loadBMP(const string& filename) -> bool;
|
2021-02-08 18:11:00 +09:00
|
|
|
auto loadBMP(const u8* data, u32 size) -> bool;
|
2020-04-05 10:19:00 +09:00
|
|
|
auto loadPNG(const string& filename) -> bool;
|
2021-02-08 18:11:00 +09:00
|
|
|
auto loadPNG(const u8* data, u32 size) -> bool;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
//interpolation.hpp
|
2021-02-08 18:11:00 +09:00
|
|
|
auto isplit(u64* component, u64 color) -> void;
|
|
|
|
auto imerge(const u64* component) -> u64;
|
|
|
|
auto interpolate1f(u64 a, u64 b, f64 x) -> u64;
|
|
|
|
auto interpolate1f(u64 a, u64 b, u64 c, u64 d, f64 x, f64 y) -> u64;
|
|
|
|
auto interpolate1i(s64 a, s64 b, u32 x) -> u64;
|
|
|
|
auto interpolate1i(s64 a, s64 b, s64 c, s64 d, u32 x, u32 y) -> u64;
|
|
|
|
auto interpolate4f(u64 a, u64 b, f64 x) -> u64;
|
|
|
|
auto interpolate4f(u64 a, u64 b, u64 c, u64 d, f64 x, f64 y) -> u64;
|
|
|
|
auto interpolate4i(u64 a, u64 b, u32 x) -> u64;
|
|
|
|
auto interpolate4i(u64 a, u64 b, u64 c, u64 d, u32 x, u32 y) -> u64;
|
|
|
|
|
|
|
|
u8* _data = nullptr;
|
|
|
|
u32 _width = 0;
|
|
|
|
u32 _height = 0;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
bool _endian = 0; //0 = lsb, 1 = msb
|
2021-02-08 18:11:00 +09:00
|
|
|
u32 _depth = 32;
|
2018-08-04 20:44:00 +09:00
|
|
|
|
|
|
|
channel _alpha{255u << 24, 8, 24};
|
|
|
|
channel _red {255u << 16, 8, 16};
|
|
|
|
channel _green{255u << 8, 8, 8};
|
|
|
|
channel _blue {255u << 0, 8, 0};
|
|
|
|
};
|
|
|
|
|
2021-09-04 00:07:37 +09:00
|
|
|
struct multiFactorImage : public image {
|
|
|
|
using image::image;
|
|
|
|
|
|
|
|
multiFactorImage(const multiFactorImage& source);
|
|
|
|
multiFactorImage(multiFactorImage&& source);
|
|
|
|
multiFactorImage(const image& lowDPI, const image& highDPI);
|
|
|
|
multiFactorImage(const image& source);
|
|
|
|
multiFactorImage(image&& source);
|
|
|
|
multiFactorImage();
|
|
|
|
~multiFactorImage();
|
|
|
|
|
|
|
|
auto operator=(const multiFactorImage& source) -> multiFactorImage&;
|
|
|
|
auto operator=(multiFactorImage&& source) -> multiFactorImage&;
|
|
|
|
|
|
|
|
auto operator==(const multiFactorImage& source) const -> bool;
|
|
|
|
auto operator!=(const multiFactorImage& source) const -> bool;
|
|
|
|
|
|
|
|
const image& lowDPI() const { return *this; }
|
|
|
|
const image& highDPI() const { return _highDPI; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
image _highDPI;
|
|
|
|
};
|
|
|
|
|
2018-08-04 20:44:00 +09:00
|
|
|
}
|
|
|
|
|
2014-01-13 18:35:46 +09:00
|
|
|
#include <nall/image/static.hpp>
|
|
|
|
#include <nall/image/core.hpp>
|
|
|
|
#include <nall/image/load.hpp>
|
|
|
|
#include <nall/image/interpolation.hpp>
|
|
|
|
#include <nall/image/fill.hpp>
|
|
|
|
#include <nall/image/scale.hpp>
|
|
|
|
#include <nall/image/blend.hpp>
|
|
|
|
#include <nall/image/utility.hpp>
|
2021-09-04 00:07:37 +09:00
|
|
|
#include <nall/image/multifactor.hpp>
|