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 03:22:54 +00:00
|
|
|
#ifndef NALL_IMAGE_HPP
|
|
|
|
#define NALL_IMAGE_HPP
|
|
|
|
|
|
|
|
#include <nall/bmp.hpp>
|
2012-02-09 12:53:55 +00:00
|
|
|
#include <nall/filemap.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 03:22:54 +00:00
|
|
|
#include <nall/interpolation.hpp>
|
|
|
|
#include <nall/png.hpp>
|
|
|
|
#include <nall/stdint.hpp>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
struct image {
|
2013-11-28 10:29:01 +00:00
|
|
|
uint8_t* data = nullptr;
|
|
|
|
unsigned width = 0;
|
2013-05-02 11:25:45 +00:00
|
|
|
unsigned height = 0;
|
2013-11-28 10:29:01 +00:00
|
|
|
unsigned pitch = 0;
|
|
|
|
unsigned size = 0;
|
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 03:22:54 +00:00
|
|
|
|
2013-12-07 09:12:37 +00:00
|
|
|
bool endian = 0; //0 = lsb, 1 = msb
|
2013-11-28 10:29:01 +00:00
|
|
|
unsigned depth = 32;
|
2013-12-07 09:12:37 +00:00
|
|
|
unsigned stride = 4;
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
struct Channel {
|
|
|
|
uint64_t mask;
|
|
|
|
unsigned depth;
|
|
|
|
unsigned shift;
|
2012-08-11 02:18:19 +00:00
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool operator==(const Channel& source) {
|
2012-08-11 02:18:19 +00:00
|
|
|
return mask == source.mask && depth == source.depth && shift == source.shift;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool operator!=(const Channel& source) {
|
2012-08-11 02:18:19 +00:00
|
|
|
return !operator==(source);
|
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
};
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
enum class blend : unsigned {
|
|
|
|
add,
|
|
|
|
sourceAlpha, //color = sourceColor * sourceAlpha + targetColor * (1 - sourceAlpha)
|
|
|
|
sourceColor, //color = sourceColor
|
|
|
|
targetAlpha, //color = targetColor * targetAlpha + sourceColor * (1 - targetAlpha)
|
|
|
|
targetColor, //color = targetColor
|
|
|
|
};
|
|
|
|
|
|
|
|
Channel alpha = {255u << 24, 8u, 24u};
|
|
|
|
Channel red = {255u << 16, 8u, 16u};
|
|
|
|
Channel green = {255u << 8, 8u, 8u};
|
|
|
|
Channel blue = {255u << 0, 8u, 0u};
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
typedef double (*interpolation)(double, double, double, double, double);
|
|
|
|
static inline unsigned bitDepth(uint64_t color);
|
|
|
|
static inline unsigned bitShift(uint64_t color);
|
|
|
|
static inline uint64_t normalize(uint64_t color, unsigned sourceDepth, unsigned targetDepth);
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool operator==(const image& source);
|
|
|
|
inline bool operator!=(const image& source);
|
2012-08-11 02:18:19 +00:00
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline image& operator=(const image& source);
|
|
|
|
inline image& operator=(image&& source);
|
|
|
|
inline image(const image& source);
|
|
|
|
inline image(image&& source);
|
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 03:22:54 +00:00
|
|
|
inline image(bool endian, unsigned depth, uint64_t alphaMask, uint64_t redMask, uint64_t greenMask, uint64_t blueMask);
|
2013-05-02 11:25:45 +00:00
|
|
|
inline image(const string& filename);
|
|
|
|
inline image(const uint8_t* data, unsigned size);
|
2012-01-26 06:50:09 +00:00
|
|
|
inline image();
|
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 03:22:54 +00:00
|
|
|
inline ~image();
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline uint64_t read(const uint8_t* data) const;
|
|
|
|
inline void write(uint8_t* data, uint64_t value) const;
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
inline void free();
|
2012-06-18 10:13:51 +00:00
|
|
|
inline bool empty() const;
|
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 03:22:54 +00:00
|
|
|
inline void allocate(unsigned width, unsigned height);
|
2013-11-28 10:29:01 +00:00
|
|
|
inline bool crop(unsigned x, unsigned y, unsigned width, unsigned height);
|
|
|
|
inline void impose(blend mode, unsigned targetX, unsigned targetY, image source, unsigned x, unsigned y, unsigned width, unsigned height);
|
|
|
|
inline void fill(uint64_t color = 0);
|
|
|
|
inline void gradient(uint64_t a, uint64_t b, uint64_t c, uint64_t d);
|
|
|
|
inline void horizontalGradient(uint64_t a, uint64_t b);
|
|
|
|
inline void verticalGradient(uint64_t a, uint64_t b);
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool load(const string& filename);
|
|
|
|
//inline bool loadBMP(const uint8_t* data, unsigned size);
|
|
|
|
inline bool loadPNG(const uint8_t* data, unsigned size);
|
2013-11-28 10:29:01 +00:00
|
|
|
inline void scale(unsigned width, unsigned height, bool linear = true);
|
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 03:22:54 +00:00
|
|
|
inline void transform(bool endian, unsigned depth, uint64_t alphaMask, uint64_t redMask, uint64_t greenMask, uint64_t blueMask);
|
|
|
|
inline void alphaBlend(uint64_t alphaColor);
|
|
|
|
|
|
|
|
protected:
|
2013-11-28 10:29:01 +00:00
|
|
|
inline uint8_t* allocate(unsigned width, unsigned height, unsigned stride);
|
|
|
|
alwaysinline uint64_t interpolate1D(int64_t a, int64_t b, uint32_t x);
|
|
|
|
alwaysinline uint64_t interpolate2D(int64_t a, int64_t b, int64_t c, int64_t d, uint32_t x, uint32_t y);
|
|
|
|
inline void scaleLinearWidth(unsigned width);
|
|
|
|
inline void scaleLinearHeight(unsigned height);
|
|
|
|
inline void scaleLinear(unsigned width, unsigned height);
|
|
|
|
inline void scaleNearest(unsigned width, unsigned height);
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool loadBMP(const string& filename);
|
|
|
|
inline bool loadPNG(const string& filename);
|
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 03:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//static
|
|
|
|
|
|
|
|
unsigned image::bitDepth(uint64_t color) {
|
|
|
|
unsigned depth = 0;
|
|
|
|
if(color) while((color & 1) == 0) color >>= 1;
|
|
|
|
while((color & 1) == 1) { color >>= 1; depth++; }
|
|
|
|
return depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned image::bitShift(uint64_t color) {
|
|
|
|
unsigned shift = 0;
|
|
|
|
if(color) while((color & 1) == 0) { color >>= 1; shift++; }
|
|
|
|
return shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t image::normalize(uint64_t color, unsigned sourceDepth, unsigned targetDepth) {
|
2013-12-03 10:01:59 +00:00
|
|
|
if(sourceDepth == 0 || targetDepth == 0) return 0;
|
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 03:22:54 +00:00
|
|
|
while(sourceDepth < targetDepth) {
|
|
|
|
color = (color << sourceDepth) | color;
|
|
|
|
sourceDepth += sourceDepth;
|
|
|
|
}
|
|
|
|
if(targetDepth < sourceDepth) color >>= (sourceDepth - targetDepth);
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
//public
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
bool image::operator==(const image& source) {
|
2012-08-11 02:18:19 +00:00
|
|
|
if(width != source.width) return false;
|
|
|
|
if(height != source.height) return false;
|
|
|
|
if(pitch != source.pitch) return false;
|
|
|
|
|
|
|
|
if(endian != source.endian) return false;
|
|
|
|
if(stride != source.stride) return false;
|
|
|
|
|
|
|
|
if(alpha != source.alpha) return false;
|
|
|
|
if(red != source.red) return false;
|
|
|
|
if(green != source.green) return false;
|
|
|
|
if(blue != source.blue) return false;
|
|
|
|
|
|
|
|
return memcmp(data, source.data, width * height * stride) == 0;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
bool image::operator!=(const image& source) {
|
2012-08-11 02:18:19 +00:00
|
|
|
return !operator==(source);
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
image& image::operator=(const image& source) {
|
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 03:22:54 +00:00
|
|
|
free();
|
|
|
|
|
|
|
|
width = source.width;
|
|
|
|
height = source.height;
|
|
|
|
pitch = source.pitch;
|
2013-11-28 10:29:01 +00:00
|
|
|
size = source.size;
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
endian = source.endian;
|
|
|
|
stride = source.stride;
|
|
|
|
|
|
|
|
alpha = source.alpha;
|
|
|
|
red = source.red;
|
|
|
|
green = source.green;
|
|
|
|
blue = source.blue;
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
data = allocate(width, height, stride);
|
|
|
|
memcpy(data, source.data, source.size);
|
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 03:22:54 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
image& image::operator=(image&& source) {
|
2012-08-11 02:18:19 +00:00
|
|
|
free();
|
|
|
|
|
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 03:22:54 +00:00
|
|
|
width = source.width;
|
|
|
|
height = source.height;
|
|
|
|
pitch = source.pitch;
|
2013-11-28 10:29:01 +00:00
|
|
|
size = source.size;
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
endian = source.endian;
|
|
|
|
stride = source.stride;
|
|
|
|
|
|
|
|
alpha = source.alpha;
|
|
|
|
red = source.red;
|
|
|
|
green = source.green;
|
|
|
|
blue = source.blue;
|
|
|
|
|
|
|
|
data = source.data;
|
|
|
|
source.data = nullptr;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
image::image(const image& source) {
|
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 03:22:54 +00:00
|
|
|
operator=(source);
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
image::image(image&& source) {
|
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 03:22:54 +00:00
|
|
|
operator=(std::forward<image>(source));
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
image::image(bool endian, unsigned depth, uint64_t alphaMask, uint64_t redMask, uint64_t greenMask, uint64_t blueMask) {
|
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 03:22:54 +00:00
|
|
|
this->endian = endian;
|
2013-11-28 10:29:01 +00:00
|
|
|
this->depth = depth;
|
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 03:22:54 +00:00
|
|
|
this->stride = (depth / 8) + ((depth & 7) > 0);
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
alpha = {alphaMask, bitDepth(alphaMask), bitShift(alphaMask)};
|
2013-11-28 10:29:01 +00:00
|
|
|
red = {redMask, bitDepth(redMask), bitShift(redMask )};
|
2013-05-02 11:25:45 +00:00
|
|
|
green = {greenMask, bitDepth(greenMask), bitShift(greenMask)};
|
2013-11-28 10:29:01 +00:00
|
|
|
blue = {blueMask, bitDepth(blueMask), bitShift(blueMask )};
|
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 03:22:54 +00:00
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
image::image(const string& filename) {
|
2012-06-18 10:13:51 +00:00
|
|
|
load(filename);
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
image::image(const uint8_t* data, unsigned size) {
|
2012-06-18 10:13:51 +00:00
|
|
|
loadPNG(data, size);
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
image::image() {
|
2012-01-26 06:50:09 +00:00
|
|
|
}
|
|
|
|
|
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 03:22:54 +00:00
|
|
|
image::~image() {
|
|
|
|
free();
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
uint64_t image::read(const uint8_t* data) const {
|
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 03:22:54 +00:00
|
|
|
uint64_t result = 0;
|
|
|
|
if(endian == 0) {
|
|
|
|
for(signed n = stride - 1; n >= 0; n--) result = (result << 8) | data[n];
|
|
|
|
} else {
|
|
|
|
for(signed n = 0; n < stride; n++) result = (result << 8) | data[n];
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
void image::write(uint8_t* data, uint64_t value) const {
|
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 03:22:54 +00:00
|
|
|
if(endian == 0) {
|
|
|
|
for(signed n = 0; n < stride; n++) { data[n] = value; value >>= 8; }
|
|
|
|
} else {
|
|
|
|
for(signed n = stride - 1; n >= 0; n--) { data[n] = value; value >>= 8; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void image::free() {
|
|
|
|
if(data) delete[] data;
|
|
|
|
data = nullptr;
|
|
|
|
}
|
|
|
|
|
2012-06-18 10:13:51 +00:00
|
|
|
bool image::empty() const {
|
|
|
|
if(data == nullptr) return true;
|
|
|
|
if(width == 0 || height == 0) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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 03:22:54 +00:00
|
|
|
void image::allocate(unsigned width, unsigned height) {
|
2011-12-12 10:59:53 +00:00
|
|
|
if(data != nullptr && this->width == width && this->height == height) return;
|
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 03:22:54 +00:00
|
|
|
free();
|
2013-11-28 10:29:01 +00:00
|
|
|
data = allocate(width, height, stride);
|
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 03:22:54 +00:00
|
|
|
pitch = width * stride;
|
2013-11-28 10:29:01 +00:00
|
|
|
size = height * pitch;
|
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 03:22:54 +00:00
|
|
|
this->width = width;
|
|
|
|
this->height = height;
|
|
|
|
}
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
void image::fill(uint64_t color) {
|
|
|
|
uint8_t* dp = data;
|
2011-12-12 10:59:53 +00:00
|
|
|
for(unsigned n = 0; n < width * height; n++) {
|
|
|
|
write(dp, color);
|
|
|
|
dp += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
void image::gradient(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
|
|
|
|
//create gradient by scaling 2x2 image using linear interpolation
|
|
|
|
//replace data with gradient data to prevent extra copy
|
|
|
|
delete[] data;
|
|
|
|
nall::image gradient;
|
|
|
|
gradient.endian = endian, gradient.depth = depth, gradient.stride = stride;
|
|
|
|
gradient.alpha = alpha, gradient.red = red, gradient.green = green, gradient.blue = blue;
|
|
|
|
gradient.allocate(2, 2);
|
|
|
|
uint8_t* dp = gradient.data;
|
|
|
|
gradient.write(dp, a); dp += stride;
|
|
|
|
gradient.write(dp, b); dp += stride;
|
|
|
|
gradient.write(dp, c); dp += stride;
|
|
|
|
gradient.write(dp, d); dp += stride;
|
|
|
|
gradient.scale(width, height);
|
|
|
|
data = gradient.data;
|
|
|
|
gradient.data = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void image::horizontalGradient(uint64_t a, uint64_t b) {
|
|
|
|
gradient(a, b, a, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
void image::verticalGradient(uint64_t a, uint64_t b) {
|
|
|
|
gradient(a, a, b, b);
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
bool image::load(const string& filename) {
|
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 03:22:54 +00:00
|
|
|
if(loadBMP(filename) == true) return true;
|
|
|
|
if(loadPNG(filename) == true) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
bool image::crop(unsigned outputX, unsigned outputY, unsigned outputWidth, unsigned outputHeight) {
|
|
|
|
if(outputX + outputWidth > width) return false;
|
|
|
|
if(outputY + outputHeight > height) return false;
|
|
|
|
|
|
|
|
uint8_t* outputData = allocate(outputWidth, outputHeight, stride);
|
|
|
|
unsigned outputPitch = outputWidth * stride;
|
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
for(unsigned y = 0; y < outputHeight; y++) {
|
|
|
|
const uint8_t* sp = data + pitch * (outputY + y) + stride * outputX;
|
|
|
|
uint8_t* dp = outputData + outputPitch * y;
|
|
|
|
for(unsigned x = 0; x < outputWidth; x++) {
|
|
|
|
write(dp, read(sp));
|
|
|
|
sp += stride;
|
|
|
|
dp += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] data;
|
|
|
|
data = outputData;
|
|
|
|
width = outputWidth;
|
|
|
|
height = outputHeight;
|
|
|
|
pitch = outputPitch;
|
|
|
|
size = width * pitch;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void image::impose(blend mode, unsigned targetX, unsigned targetY, image source, unsigned sourceX, unsigned sourceY, unsigned sourceWidth, unsigned sourceHeight) {
|
|
|
|
source.transform(endian, depth, alpha.mask, red.mask, green.mask, blue.mask);
|
|
|
|
|
|
|
|
for(unsigned y = 0; y < sourceHeight; y++) {
|
|
|
|
const uint8_t* sp = source.data + source.pitch * (sourceY + y) + source.stride * sourceX;
|
|
|
|
uint8_t* dp = data + pitch * (targetY + y) + stride * targetX;
|
|
|
|
for(unsigned x = 0; x < sourceWidth; x++) {
|
|
|
|
uint64_t sourceColor = source.read(sp);
|
|
|
|
uint64_t targetColor = read(dp);
|
|
|
|
|
|
|
|
int64_t sa = (sourceColor & alpha.mask) >> alpha.shift;
|
|
|
|
int64_t sr = (sourceColor & red.mask ) >> red.shift;
|
|
|
|
int64_t sg = (sourceColor & green.mask) >> green.shift;
|
|
|
|
int64_t sb = (sourceColor & blue.mask ) >> blue.shift;
|
|
|
|
|
|
|
|
int64_t da = (targetColor & alpha.mask) >> alpha.shift;
|
|
|
|
int64_t dr = (targetColor & red.mask ) >> red.shift;
|
|
|
|
int64_t dg = (targetColor & green.mask) >> green.shift;
|
|
|
|
int64_t db = (targetColor & blue.mask ) >> blue.shift;
|
|
|
|
|
|
|
|
uint64_t a, r, g, b;
|
|
|
|
|
|
|
|
switch(mode) {
|
|
|
|
case blend::add:
|
|
|
|
a = max(sa, da);
|
|
|
|
r = min(red.mask >> red.shift, ((sr * sa) >> alpha.depth) + ((dr * da) >> alpha.depth));
|
|
|
|
g = min(green.mask >> green.shift, ((sg * sa) >> alpha.depth) + ((dg * da) >> alpha.depth));
|
|
|
|
b = min(blue.mask >> blue.shift, ((sb * sa) >> alpha.depth) + ((db * da) >> alpha.depth));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case blend::sourceAlpha:
|
|
|
|
a = max(sa, da);
|
|
|
|
r = dr + (((sr - dr) * sa) >> alpha.depth);
|
|
|
|
g = dg + (((sg - dg) * sa) >> alpha.depth);
|
|
|
|
b = db + (((sb - db) * sa) >> alpha.depth);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case blend::sourceColor:
|
|
|
|
a = sa;
|
|
|
|
r = sr;
|
|
|
|
g = sg;
|
|
|
|
b = sb;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case blend::targetAlpha:
|
|
|
|
a = max(sa, da);
|
|
|
|
r = sr + (((dr - sr) * da) >> alpha.depth);
|
|
|
|
g = sg + (((dg - sg) * da) >> alpha.depth);
|
|
|
|
b = sb + (((db - sb) * da) >> alpha.depth);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case blend::targetColor:
|
|
|
|
a = da;
|
|
|
|
r = dr;
|
|
|
|
g = dg;
|
|
|
|
b = db;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
write(dp, (a << alpha.shift) | (r << red.shift) | (g << green.shift) | (b << blue.shift));
|
|
|
|
sp += source.stride;
|
|
|
|
dp += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void image::scale(unsigned outputWidth, unsigned outputHeight, bool linear) {
|
|
|
|
if(width == outputWidth && height == outputHeight) return; //no scaling necessary
|
|
|
|
if(linear == false) return scaleNearest(outputWidth, outputHeight);
|
|
|
|
|
|
|
|
if(width == outputWidth ) return scaleLinearHeight(outputHeight);
|
|
|
|
if(height == outputHeight) return scaleLinearWidth(outputWidth);
|
|
|
|
|
|
|
|
//find fastest scaling method, based on number of interpolation operations required
|
|
|
|
//magnification usually benefits from two-pass linear interpolation
|
|
|
|
//minification usually benefits from one-pass bilinear interpolation
|
|
|
|
unsigned d1wh = ((width * outputWidth ) + (outputWidth * outputHeight)) * 1;
|
|
|
|
unsigned d1hw = ((height * outputHeight) + (outputWidth * outputHeight)) * 1;
|
|
|
|
unsigned d2wh = (outputWidth * outputHeight) * 3;
|
|
|
|
|
|
|
|
if(d1wh <= d1hw && d1wh <= d2wh) return scaleLinearWidth(outputWidth), scaleLinearHeight(outputHeight);
|
|
|
|
if(d1hw <= d2wh) return scaleLinearHeight(outputHeight), scaleLinearWidth(outputWidth);
|
|
|
|
return scaleLinear(outputWidth, outputHeight);
|
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 03:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void image::transform(bool outputEndian, unsigned outputDepth, uint64_t outputAlphaMask, uint64_t outputRedMask, uint64_t outputGreenMask, uint64_t outputBlueMask) {
|
2013-11-28 10:29:01 +00:00
|
|
|
if(endian == outputEndian && depth == outputDepth && alpha.mask == outputAlphaMask && red.mask == outputRedMask && green.mask == outputGreenMask && blue.mask == outputBlueMask) return;
|
|
|
|
|
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 03:22:54 +00:00
|
|
|
image output(outputEndian, outputDepth, outputAlphaMask, outputRedMask, outputGreenMask, outputBlueMask);
|
|
|
|
output.allocate(width, height);
|
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
for(unsigned y = 0; y < height; y++) {
|
2013-11-28 10:29:01 +00:00
|
|
|
const uint8_t* sp = data + pitch * y;
|
2013-05-02 11:25:45 +00:00
|
|
|
uint8_t* dp = output.data + output.pitch * y;
|
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 03:22:54 +00:00
|
|
|
for(unsigned x = 0; x < width; x++) {
|
|
|
|
uint64_t color = read(sp);
|
|
|
|
sp += stride;
|
|
|
|
|
|
|
|
uint64_t a = (color & alpha.mask) >> alpha.shift;
|
|
|
|
uint64_t r = (color & red.mask) >> red.shift;
|
|
|
|
uint64_t g = (color & green.mask) >> green.shift;
|
|
|
|
uint64_t b = (color & blue.mask) >> blue.shift;
|
|
|
|
|
|
|
|
a = normalize(a, alpha.depth, output.alpha.depth);
|
|
|
|
r = normalize(r, red.depth, output.red.depth);
|
|
|
|
g = normalize(g, green.depth, output.green.depth);
|
|
|
|
b = normalize(b, blue.depth, output.blue.depth);
|
|
|
|
|
2011-12-12 10:59:53 +00:00
|
|
|
output.write(dp, (a << output.alpha.shift) | (r << output.red.shift) | (g << output.green.shift) | (b << output.blue.shift));
|
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 03:22:54 +00:00
|
|
|
dp += output.stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
operator=(std::move(output));
|
|
|
|
}
|
|
|
|
|
|
|
|
void image::alphaBlend(uint64_t alphaColor) {
|
2013-11-28 10:29:01 +00:00
|
|
|
uint64_t alphaR = (alphaColor & red.mask ) >> red.shift;
|
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 03:22:54 +00:00
|
|
|
uint64_t alphaG = (alphaColor & green.mask) >> green.shift;
|
2013-11-28 10:29:01 +00:00
|
|
|
uint64_t alphaB = (alphaColor & blue.mask ) >> blue.shift;
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
for(unsigned y = 0; y < height; y++) {
|
2013-05-02 11:25:45 +00:00
|
|
|
uint8_t* dp = data + pitch * y;
|
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 03:22:54 +00:00
|
|
|
for(unsigned x = 0; x < width; x++) {
|
|
|
|
uint64_t color = read(dp);
|
|
|
|
|
|
|
|
uint64_t colorA = (color & alpha.mask) >> alpha.shift;
|
2013-11-28 10:29:01 +00:00
|
|
|
uint64_t colorR = (color & red.mask ) >> red.shift;
|
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 03:22:54 +00:00
|
|
|
uint64_t colorG = (color & green.mask) >> green.shift;
|
2013-11-28 10:29:01 +00:00
|
|
|
uint64_t colorB = (color & blue.mask ) >> blue.shift;
|
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 03:22:54 +00:00
|
|
|
double alphaScale = (double)colorA / (double)((1 << alpha.depth) - 1);
|
|
|
|
|
|
|
|
colorA = (1 << alpha.depth) - 1;
|
|
|
|
colorR = (colorR * alphaScale) + (alphaR * (1.0 - alphaScale));
|
|
|
|
colorG = (colorG * alphaScale) + (alphaG * (1.0 - alphaScale));
|
|
|
|
colorB = (colorB * alphaScale) + (alphaB * (1.0 - alphaScale));
|
|
|
|
|
2011-12-12 10:59:53 +00:00
|
|
|
write(dp, (colorA << alpha.shift) | (colorR << red.shift) | (colorG << green.shift) | (colorB << blue.shift));
|
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 03:22:54 +00:00
|
|
|
dp += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//protected
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
uint8_t* image::allocate(unsigned width, unsigned height, unsigned stride) {
|
|
|
|
//allocate 1x1 larger than requested; so that linear interpolation does not require bounds-checking
|
|
|
|
unsigned size = width * height * stride;
|
|
|
|
unsigned padding = width * stride + stride;
|
|
|
|
uint8_t* data = new uint8_t[size + padding];
|
|
|
|
memset(data + size, 0x00, padding);
|
|
|
|
return data;
|
|
|
|
}
|
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 03:22:54 +00:00
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
//fixed-point reduction of: a * (1 - x) + b * x
|
|
|
|
uint64_t image::interpolate1D(int64_t a, int64_t b, uint32_t x) {
|
|
|
|
return a + (((b - a) * x) >> 32); //a + (b - a) * x
|
|
|
|
}
|
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 03:22:54 +00:00
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
//fixed-point reduction of: a * (1 - x) * (1 - y) + b * x * (1 - y) + c * (1 - x) * y + d * x * y
|
|
|
|
uint64_t image::interpolate2D(int64_t a, int64_t b, int64_t c, int64_t d, uint32_t x, uint32_t y) {
|
|
|
|
a = a + (((b - a) * x) >> 32); //a + (b - a) * x
|
|
|
|
c = c + (((d - c) * x) >> 32); //c + (d - c) * x
|
|
|
|
return a + (((c - a) * y) >> 32); //a + (c - a) * y
|
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 03:22:54 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
void image::scaleLinearWidth(unsigned outputWidth) {
|
|
|
|
uint8_t* outputData = allocate(outputWidth, height, stride);
|
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 03:22:54 +00:00
|
|
|
unsigned outputPitch = outputWidth * stride;
|
2013-11-28 10:29:01 +00:00
|
|
|
uint64_t xstride = ((uint64_t)(width - 1) << 32) / max(1u, outputWidth - 1);
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
for(unsigned y = 0; y < height; y++) {
|
2013-11-28 10:29:01 +00:00
|
|
|
uint64_t xfraction = 0;
|
|
|
|
|
|
|
|
const uint8_t* sp = data + pitch * y;
|
2013-05-02 11:25:45 +00:00
|
|
|
uint8_t* dp = outputData + outputPitch * y;
|
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 03:22:54 +00:00
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
uint64_t a = read(sp);
|
|
|
|
uint64_t b = read(sp + stride);
|
|
|
|
sp += stride;
|
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 03:22:54 +00:00
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
unsigned x = 0;
|
2013-12-07 09:12:37 +00:00
|
|
|
while(true) {
|
2013-11-28 10:29:01 +00:00
|
|
|
while(xfraction < 0x100000000 && x++ < outputWidth) {
|
|
|
|
uint64_t A = interpolate1D((a & alpha.mask) >> alpha.shift, (b & alpha.mask) >> alpha.shift, xfraction);
|
|
|
|
uint64_t R = interpolate1D((a & red.mask ) >> red.shift , (b & red.mask ) >> red.shift, xfraction);
|
|
|
|
uint64_t G = interpolate1D((a & green.mask) >> green.shift, (b & green.mask) >> green.shift, xfraction);
|
|
|
|
uint64_t B = interpolate1D((a & blue.mask ) >> blue.shift , (b & blue.mask ) >> blue.shift, xfraction);
|
|
|
|
|
|
|
|
write(dp, (A << alpha.shift) | (R << red.shift) | (G << green.shift) | (B << blue.shift));
|
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 03:22:54 +00:00
|
|
|
dp += stride;
|
2013-11-28 10:29:01 +00:00
|
|
|
xfraction += xstride;
|
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 03:22:54 +00:00
|
|
|
}
|
2013-12-07 09:12:37 +00:00
|
|
|
if(x >= outputWidth) break;
|
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 03:22:54 +00:00
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
sp += stride;
|
|
|
|
a = b;
|
|
|
|
b = read(sp);
|
|
|
|
xfraction -= 0x100000000;
|
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 03:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free();
|
|
|
|
data = outputData;
|
|
|
|
width = outputWidth;
|
2013-11-28 10:29:01 +00:00
|
|
|
pitch = outputPitch;
|
|
|
|
size = height * pitch;
|
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 03:22:54 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
void image::scaleLinearHeight(unsigned outputHeight) {
|
|
|
|
uint8_t* outputData = allocate(width, outputHeight, stride);
|
|
|
|
uint64_t ystride = ((uint64_t)(height - 1) << 32) / max(1u, outputHeight - 1);
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
for(unsigned x = 0; x < width; x++) {
|
2013-11-28 10:29:01 +00:00
|
|
|
uint64_t yfraction = 0;
|
|
|
|
|
|
|
|
const uint8_t* sp = data + stride * x;
|
2013-05-02 11:25:45 +00:00
|
|
|
uint8_t* dp = outputData + stride * x;
|
2013-11-28 10:29:01 +00:00
|
|
|
|
|
|
|
uint64_t a = read(sp);
|
|
|
|
uint64_t b = read(sp + pitch);
|
|
|
|
sp += pitch;
|
|
|
|
|
|
|
|
unsigned y = 0;
|
2013-12-07 09:12:37 +00:00
|
|
|
while(true) {
|
2013-11-28 10:29:01 +00:00
|
|
|
while(yfraction < 0x100000000 && y++ < outputHeight) {
|
|
|
|
uint64_t A = interpolate1D((a & alpha.mask) >> alpha.shift, (b & alpha.mask) >> alpha.shift, yfraction);
|
|
|
|
uint64_t R = interpolate1D((a & red.mask ) >> red.shift, (b & red.mask ) >> red.shift, yfraction);
|
|
|
|
uint64_t G = interpolate1D((a & green.mask) >> green.shift, (b & green.mask) >> green.shift, yfraction);
|
|
|
|
uint64_t B = interpolate1D((a & blue.mask ) >> blue.shift, (b & blue.mask ) >> blue.shift, yfraction);
|
|
|
|
|
|
|
|
write(dp, (A << alpha.shift) | (R << red.shift) | (G << green.shift) | (B << blue.shift));
|
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 03:22:54 +00:00
|
|
|
dp += pitch;
|
2013-11-28 10:29:01 +00:00
|
|
|
yfraction += ystride;
|
|
|
|
}
|
2013-12-07 09:12:37 +00:00
|
|
|
if(y >= outputHeight) break;
|
2013-11-28 10:29:01 +00:00
|
|
|
|
|
|
|
sp += pitch;
|
|
|
|
a = b;
|
|
|
|
b = read(sp);
|
|
|
|
yfraction -= 0x100000000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free();
|
|
|
|
data = outputData;
|
|
|
|
height = outputHeight;
|
|
|
|
size = height * pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
void image::scaleLinear(unsigned outputWidth, unsigned outputHeight) {
|
|
|
|
uint8_t* outputData = allocate(outputWidth, outputHeight, stride);
|
|
|
|
unsigned outputPitch = outputWidth * stride;
|
|
|
|
|
|
|
|
uint64_t xstride = ((uint64_t)(width - 1) << 32) / max(1u, outputWidth - 1);
|
|
|
|
uint64_t ystride = ((uint64_t)(height - 1) << 32) / max(1u, outputHeight - 1);
|
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
for(unsigned y = 0; y < outputHeight; y++) {
|
|
|
|
uint64_t yfraction = ystride * y;
|
|
|
|
uint64_t xfraction = 0;
|
|
|
|
|
|
|
|
const uint8_t* sp = data + pitch * (yfraction >> 32);
|
|
|
|
uint8_t* dp = outputData + outputPitch * y;
|
|
|
|
|
|
|
|
uint64_t a = read(sp);
|
|
|
|
uint64_t b = read(sp + stride);
|
|
|
|
uint64_t c = read(sp + pitch);
|
|
|
|
uint64_t d = read(sp + pitch + stride);
|
|
|
|
sp += stride;
|
|
|
|
|
|
|
|
unsigned x = 0;
|
2013-12-07 09:12:37 +00:00
|
|
|
while(true) {
|
2013-11-28 10:29:01 +00:00
|
|
|
while(xfraction < 0x100000000 && x++ < outputWidth) {
|
|
|
|
uint64_t A = interpolate2D((a & alpha.mask) >> alpha.shift, (b & alpha.mask) >> alpha.shift, (c & alpha.mask) >> alpha.shift, (d & alpha.mask) >> alpha.shift, xfraction, yfraction);
|
|
|
|
uint64_t R = interpolate2D((a & red.mask ) >> red.shift, (b & red.mask ) >> red.shift, (c & red.mask ) >> red.shift, (d & red.mask ) >> red.shift, xfraction, yfraction);
|
|
|
|
uint64_t G = interpolate2D((a & green.mask) >> green.shift, (b & green.mask) >> green.shift, (c & green.mask) >> green.shift, (d & green.mask) >> green.shift, xfraction, yfraction);
|
|
|
|
uint64_t B = interpolate2D((a & blue.mask ) >> blue.shift, (b & blue.mask ) >> blue.shift, (c & blue.mask ) >> blue.shift, (d & blue.mask ) >> blue.shift, xfraction, yfraction);
|
|
|
|
|
|
|
|
write(dp, (A << alpha.shift) | (R << red.shift) | (G << green.shift) | (B << blue.shift));
|
|
|
|
dp += stride;
|
|
|
|
xfraction += xstride;
|
|
|
|
}
|
2013-12-07 09:12:37 +00:00
|
|
|
if(x >= outputWidth) break;
|
2013-11-28 10:29:01 +00:00
|
|
|
|
|
|
|
sp += stride;
|
|
|
|
a = b;
|
|
|
|
c = d;
|
|
|
|
b = read(sp);
|
|
|
|
d = read(sp + pitch);
|
|
|
|
xfraction -= 0x100000000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free();
|
|
|
|
data = outputData;
|
|
|
|
width = outputWidth;
|
|
|
|
height = outputHeight;
|
|
|
|
pitch = outputPitch;
|
|
|
|
size = height * pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
void image::scaleNearest(unsigned outputWidth, unsigned outputHeight) {
|
|
|
|
uint8_t* outputData = allocate(outputWidth, outputHeight, stride);
|
|
|
|
unsigned outputPitch = outputWidth * stride;
|
|
|
|
|
|
|
|
uint64_t xstride = ((uint64_t)width << 32) / outputWidth;
|
|
|
|
uint64_t ystride = ((uint64_t)height << 32) / outputHeight;
|
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
for(unsigned y = 0; y < outputHeight; y++) {
|
|
|
|
uint64_t yfraction = ystride * y;
|
|
|
|
uint64_t xfraction = 0;
|
|
|
|
|
|
|
|
const uint8_t* sp = data + pitch * (yfraction >> 32);
|
|
|
|
uint8_t* dp = outputData + outputPitch * y;
|
|
|
|
|
|
|
|
uint64_t a = read(sp);
|
|
|
|
|
|
|
|
unsigned x = 0;
|
2013-12-07 09:12:37 +00:00
|
|
|
while(true) {
|
2013-11-28 10:29:01 +00:00
|
|
|
while(xfraction < 0x100000000 && x++ < outputWidth) {
|
|
|
|
write(dp, a);
|
|
|
|
dp += stride;
|
|
|
|
xfraction += xstride;
|
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 03:22:54 +00:00
|
|
|
}
|
2013-12-07 09:12:37 +00:00
|
|
|
if(x >= outputWidth) break;
|
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 03:22:54 +00:00
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
sp += stride;
|
|
|
|
a = read(sp);
|
|
|
|
xfraction -= 0x100000000;
|
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 03:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free();
|
|
|
|
data = outputData;
|
2013-11-28 10:29:01 +00:00
|
|
|
width = outputWidth;
|
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 03:22:54 +00:00
|
|
|
height = outputHeight;
|
2013-11-28 10:29:01 +00:00
|
|
|
pitch = outputPitch;
|
|
|
|
size = height * pitch;
|
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 03:22:54 +00:00
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
bool image::loadBMP(const string& filename) {
|
|
|
|
uint32_t* outputData;
|
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 03:22:54 +00:00
|
|
|
unsigned outputWidth, outputHeight;
|
|
|
|
if(bmp::read(filename, outputData, outputWidth, outputHeight) == false) return false;
|
|
|
|
|
|
|
|
allocate(outputWidth, outputHeight);
|
2013-05-02 11:25:45 +00:00
|
|
|
const uint32_t* sp = outputData;
|
|
|
|
uint8_t* dp = data;
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
for(unsigned y = 0; y < outputHeight; y++) {
|
|
|
|
for(unsigned x = 0; x < outputWidth; x++) {
|
|
|
|
uint32_t color = *sp++;
|
|
|
|
uint64_t a = normalize((uint8_t)(color >> 24), 8, alpha.depth);
|
|
|
|
uint64_t r = normalize((uint8_t)(color >> 16), 8, red.depth);
|
|
|
|
uint64_t g = normalize((uint8_t)(color >> 8), 8, green.depth);
|
|
|
|
uint64_t b = normalize((uint8_t)(color >> 0), 8, blue.depth);
|
2011-12-12 10:59:53 +00:00
|
|
|
write(dp, (a << alpha.shift) | (r << red.shift) | (g << green.shift) | (b << blue.shift));
|
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 03:22:54 +00:00
|
|
|
dp += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] outputData;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
bool image::loadPNG(const uint8_t* pngData, unsigned pngSize) {
|
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 03:22:54 +00:00
|
|
|
png source;
|
2012-02-09 12:53:55 +00:00
|
|
|
if(source.decode(pngData, pngSize) == false) return false;
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
allocate(source.info.width, source.info.height);
|
2013-05-02 11:25:45 +00:00
|
|
|
const uint8_t* sp = source.data;
|
|
|
|
uint8_t* dp = data;
|
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 03:22:54 +00:00
|
|
|
|
|
|
|
auto decode = [&]() -> uint64_t {
|
|
|
|
uint64_t p, r, g, b, a;
|
|
|
|
|
|
|
|
switch(source.info.colorType) {
|
|
|
|
case 0: //L
|
|
|
|
r = g = b = source.readbits(sp);
|
|
|
|
a = (1 << source.info.bitDepth) - 1;
|
|
|
|
break;
|
|
|
|
case 2: //R,G,B
|
|
|
|
r = source.readbits(sp);
|
|
|
|
g = source.readbits(sp);
|
|
|
|
b = source.readbits(sp);
|
|
|
|
a = (1 << source.info.bitDepth) - 1;
|
|
|
|
break;
|
|
|
|
case 3: //P
|
|
|
|
p = source.readbits(sp);
|
|
|
|
r = source.info.palette[p][0];
|
|
|
|
g = source.info.palette[p][1];
|
|
|
|
b = source.info.palette[p][2];
|
|
|
|
a = (1 << source.info.bitDepth) - 1;
|
|
|
|
break;
|
|
|
|
case 4: //L,A
|
|
|
|
r = g = b = source.readbits(sp);
|
|
|
|
a = source.readbits(sp);
|
|
|
|
break;
|
|
|
|
case 6: //R,G,B,A
|
|
|
|
r = source.readbits(sp);
|
|
|
|
g = source.readbits(sp);
|
|
|
|
b = source.readbits(sp);
|
|
|
|
a = source.readbits(sp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
a = normalize(a, source.info.bitDepth, alpha.depth);
|
|
|
|
r = normalize(r, source.info.bitDepth, red.depth);
|
|
|
|
g = normalize(g, source.info.bitDepth, green.depth);
|
|
|
|
b = normalize(b, source.info.bitDepth, blue.depth);
|
|
|
|
|
2011-12-12 10:59:53 +00:00
|
|
|
return (a << alpha.shift) | (r << red.shift) | (g << green.shift) | (b << blue.shift);
|
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 03:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for(unsigned y = 0; y < height; y++) {
|
|
|
|
for(unsigned x = 0; x < width; x++) {
|
|
|
|
write(dp, decode());
|
|
|
|
dp += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
bool image::loadPNG(const string& filename) {
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
if(!file::exists(filename)) return false;
|
|
|
|
auto buffer = file::read(filename);
|
|
|
|
return loadPNG(buffer.data(), buffer.size());
|
2012-02-09 12:53:55 +00:00
|
|
|
}
|
|
|
|
|
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 03:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|