mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-08 14:38:18 +02:00
util: Generate linear<->sRGB conversion tables.
This commit is contained in:
parent
ac8e1c18f2
commit
c863f30155
1 changed files with 17 additions and 0 deletions
|
|
@ -37,6 +37,7 @@
|
|||
'''
|
||||
|
||||
|
||||
import math
|
||||
import sys
|
||||
|
||||
from u_format_pack import *
|
||||
|
|
@ -94,6 +95,20 @@ def native_type(format):
|
|||
assert False
|
||||
|
||||
|
||||
def generate_srgb_tables():
|
||||
print 'static ubyte srgb_to_linear[256] = {'
|
||||
for i in range(256):
|
||||
print ' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255))
|
||||
print '};'
|
||||
print
|
||||
print 'static ubyte linear_to_srgb[256] = {'
|
||||
print ' 0,'
|
||||
for i in range(1, 256):
|
||||
print ' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255))
|
||||
print '};'
|
||||
print
|
||||
|
||||
|
||||
def generate_format_read(format, dst_channel, dst_native_type, dst_suffix):
|
||||
'''Generate the function to read pixels from a particular format'''
|
||||
|
||||
|
|
@ -305,6 +320,8 @@ def main():
|
|||
print '#include "u_format_pack.h"'
|
||||
print
|
||||
|
||||
generate_srgb_tables()
|
||||
|
||||
type = Channel(FLOAT, False, 32)
|
||||
native_type = 'float'
|
||||
suffix = '4f'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue