|
0x80 is 128 which is half of 256, which is a byte.
I have a function called BYTE_MUL() in my code that does multiplication by 1/255 of a value, in which case 0x80 is about half.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
That's what I assumed was happening but didn't know for sure - thanks for clarifying
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
The important bit was the first part "two input layers for Photoshop blending". I saw a function with only one input layer.
The 0x80 was just a safety check. I assumed you knew, and you did, so yes:
0xff == 255/255, 0x80 == 128/255 ≈ 1/2, 0x01 == 1/255
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
In photoshop, you can superpose different layers, and decide for each how it will "blend" with the layers below.
The simplest blend way is to simply superpose the layer content, so you see at first what is on the layer on top, then what is on the layer below it but for what is on the first layer, and so on. Like a pile of cards that are not aligned, you'll see the top card and bits of the cards below it if you look from above.
And then you can apply a formula for each layer blending, that can be different for each. For the pile of cards, you can say that you want to merge only the red colors in the final rendering, or the pixels that are above a certain saturation value, or below a certain brightness, and ignore all other, or multiply the pixel values. If you have a pile of blue and red cards, and only merge red, you'll end up with a solid big chunk of merge red cards surrounded by bits of untouched blue cards below (assuming the top card is red).
As you pointed out, each of the layers have an opacity value (alpha-blending) which is independent from the blending mode.
It is quite easy to grasp if you can get in touch with a photoshop version : simply create a bunch of layers with different geometrical shapes on them, and play with the predefined blending/compistion mode for each layer.
|
|
|
|
|
In essence:
This function works, but it uses callbacks, and does the alpha blending during the callback's destination call:
static void composition_solid_source_over(const composition_params& params)
{
uint32_t color=params.color;
if(params.const_alpha != 255) color = BYTE_MUL(params.color, params.const_alpha);
uint32_t ialpha = 255 - plutovg_alpha(color);
for(int i = 0; i < params.length; i++) {
uint32_t col;
if(params.canvas->read_callback!=nullptr) {
::gfx::vector_pixel c;
params.canvas->read_callback(::gfx::point16(params.x+i,params.y),&c,params.canvas->callback_state);
col = color + BYTE_MUL(c.native_value, ialpha);
} else {
col = color;
}
if(params.canvas->write_callback!=nullptr) {
params.canvas->write_callback(::gfx::rect16(params.x+i,params.y,params.x+i,params.y),::gfx::vector_pixel(col,true),params.canvas->callback_state);
}
}
}
This one works too, even though it could be more efficient if I updated BYTE_MUL() to handle RGBA instead of ARGB:
static void direct_rgba32_composition_solid_source_over(const composition_params& params)
{
uint32_t* dest = (uint32_t*)(((uint8_t*)params.direct_rgba32) + (params.y * params.stride)) + params.x;
uint32_t color = params.color;
if(params.const_alpha != 255) color = BYTE_MUL(params.color, params.const_alpha);
uint32_t ialpha = 255 - plutovg_alpha(color);
for(int i = 0; i < params.length; i++) {
dest[i] = vector_to_rgba32(color + BYTE_MUL(rgba32_to_vector(dest[i]), ialpha));
}
}
This does not:
static void direct_rgb16_composition_solid_source_over(const composition_params& params)
{
uint16_t* dest = (uint16_t*)(((uint8_t*)params.direct_rgb16) + (params.y * params.stride)) + params.x;
uint32_t color=params.color;
if(params.const_alpha != 255) color = BYTE_MUL(params.color, params.const_alpha);
uint32_t ialpha = 255 - plutovg_alpha(color);
for(int i = 0; i < params.length; i++) {
uint32_t read_col=rgb16_to_vector(dest[i]);
uint32_t col = color + BYTE_MUL(read_col, ialpha);
dest[i]=vector_to_rgb16(col);
}
}
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
honey the codewitch wrote: This does not:
Yes, because uint32_t read_col=rgb16_to_vector(dest[i]); probably causes information loss.
|
|
|
|
|
Nah. It does cause information loss, but that's not what I'm experiencing. What I'm experiencing is outright corruption.
Corrupt image[^]
If it was just losing fidelity, I would see the edges of the shading in gradients and such, but they wouldn't be the wrong entire color.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Do not bother with Adobes monster portals. Get GIMP, free, it has the same-ish blend modes, even if naming might vary.
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
Nah, it is like all these MSOffice clones : good, but does not top the real thing.
Actually, I am still using Photshop 7 - No online licensing required, and just enough features for me to be able to know most of them.
|
|
|
|
|
We are not at all trying to "top" PS though. We are trying to avoid the Adobe portal. I was unaware that PS7 is easy to get.
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
megaadam wrote: I was unaware that PS7 is easy to get.
Want a copy?
I don't know where/how it might be available online these days. I bought my copy in 2003 -- from an online "OEM" seller.
|
|
|
|
|
Thoughts and prayers for our programmer friends from the Sunshine State (Florida), as Hurricane Milton will be making landfall this evening.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
We're still recovering from Helene!
Luckily this one is going south of us and will have minimal impact.
A home without books is a body without soul. Marcus Tullius Cicero
PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
Perspective is everything. I know someone in south Tampa and she's freaking out right now. Can't say I blame her.
Did you get through Helene ok? And of course, did all your computers survive?
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: I know someone in south Tampa and she's freaking out right now. Can't say I blame her.
Ditto, they're fixin to get hit hard, hope she stays safe.
We got though without any damage but we had about 30 trees down. We think the way some are twisted off that we had at least one tornado come through our area. There's a swath through our neighborhood were it is obvious something bad went through by the amount of damage and we are the worst hit. We bought the house because of all the beautiful trees and now there are hardly any left, turns out they were all end-of-life water oaks.
We have 3 acres with a frontage of about 300 yards and we have enough debris stacked along the road to fill an estimated 10 large dump trucks.
Luckily we had family and friends help with cleanup.
Funny while we were cleaning up we had people drive by, slowly gawking and taking pictures.
A home without books is a body without soul. Marcus Tullius Cicero
PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
Mike Hankey wrote: We got though without any damage but we had about 30 trees down Sad about the trees, that's a shame. At y'all are alive and kicking though, so there's that.
Mike Hankey wrote: We think the way some are twisted off that we had at least one tornado come through our area Was thinking the same exact thing after seeing 30 trees went down, assuming they were big trees. If it was a tornado, thank God it didn't hit your house though.
Mike Hankey wrote: We bought the house because of all the beautiful trees and now there are hardly any left, turns out they were all end-of-life water oaks.
Mike Hankey wrote: We have 3 acres with a frontage of about 300 yards and we have enough debris stacked along the road to fill an estimated 10 large dump trucks. Dang. Dem country boys know what's up. Let's just say after living in Hollywood and Vegas for almost a decade I forgot what that's like. Must be an awesome yard, even if 30 trees went down.
Mike Hankey wrote: Funny while we were cleaning up we had people drive by, slowly gawking and taking pictures. There's your 15 minutes of fame... all it took was a hurricane.
Jeremy Falcon
|
|
|
|
|
Oh and um, glad you're alive and all that.
Jeremy Falcon
|
|
|
|
|
Took a lickin and kept on tickin.
A home without books is a body without soul. Marcus Tullius Cicero
PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
Hope so Mike it looks a serious MF
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Not the best time to go see Mickey Mouse.
Stay dry everyone in the area.
Put your backups in dry bags.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
Maximilien wrote: Not the best time to go see Mickey Mouse.
At times like these, reservations aren't flying off the shelves...
Sorry, too soon.
|
|
|
|
|
Backups? What is that?
>64
It’s weird being the same age as old people. Live every day like it is your last; one day, it will be.
|
|
|
|
|
One of my colleagues lives in Venice, FL and the other is in Orlando. The owner (Venice) escaped South to Islamorada and the other is expecting wind damage/power outage but they are boarded up and should be able to handle it. Looks like I get a day off tomorrow! Either that or I will be the only one answering my phone!
"Go forth into the source" - Neal Morse
"Hope is contagious"
|
|
|
|
|
kmoorevs wrote: Either that or I will be the only one answering my phone! Supposing phone works
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
We evacuated from Tampa to Georgia on Monday, before the gridlock on the 75 started. Now we just hope for the best news tomorrow, Thursday!
Ok, I have had my coffee, so you can all come out now!
|
|
|
|