English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. System (https://eab.abime.net/forumdisplay.php?f=113)
-   -   OS wide gamma correction Part 2. (https://eab.abime.net/showthread.php?t=86708)

Thorham 09 April 2017 15:15

OS wide gamma correction Part 2.
 
After writing a simple program that patches LoadRGB4 and LoadRGB32 to apply gamma correction, which works fine, I tried to patch GetRGB32 so that it can return the original color values. Because LoadRGB32 takes 32bit values for each component, I assumed that these were just stored as is, so that I could store the original values in that (gamma corrected byte, original byte, two zero bytes). Turns out that only the top byte of each component is actually used, the rest is discarded (missed it in the docs).

Major pain :scream

Other than storing a color table for each viewport, does anyone have any ideas as how to get GetRGB32 to return the original, uncorrected color values? Note that gamma correction is lossy, so you can't just reverse it.

Perhaps the LoadRGB functions shouldn't be patched, but something else?

meynaf 10 April 2017 09:08

Quote:

Originally Posted by Thorham (Post 1151364)
Perhaps the LoadRGB functions shouldn't be patched, but something else?

You could try patching graphics.library/MakeVPort or graphics.library/MrgCop.
Or bin your old monitor and get one that does not need gamma correction :D

Thorham 10 April 2017 13:34

Quote:

Originally Posted by meynaf (Post 1151505)
You could try patching graphics.library/MakeVPort or graphics.library/MrgCop.

Yeah, that might be a good idea. Both require messing with copper lists, though.

Seems worth looking at, thanks.

Quote:

Originally Posted by meynaf (Post 1151505)
Or bin your old monitor and get one that does not need gamma correction :D

Noooooo :crying

Thorham 10 April 2017 18:48

Turns out you don't have to mess with the copper lists (thank goodness).

Basic steps:

1. Patch makevport by copying the colortable over and applying the gamma correction to the copy. Have makevport use the copy, and restore the original pointer.

2. Patch loadrgb32 to set gamma corrected colors. Make a new color table with the original colors.

3. Done :)

...or so it seems ;)

meynaf 10 April 2017 19:08

Good news. The trick seems to be catching the color data right before the coplist is made, so u don't have to store original colors. At least it was what made me suggest getting to a lower level...

Thorham 10 April 2017 19:40

It mostly works. Grabbed screens use original colors, etc. There's still a problem. Some screens don't get corrected. Probably something small.

Thorham 11 April 2017 14:29

It seems that it's impossible to get it to work completely properly like this :scream The OS probably just sticks the colors directly into the copperlist. If only it was possible to safely call this routine.

Guess it's time to look into changing a viewport's copperlist manually. Hopefully that will be a little easier than I thought.


All times are GMT +2. The time now is 15:08.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04515 seconds with 11 queries