Can PB handle 10-bit images, either on screen or in a file?
This would include RGB() and all similar 2D graphics functions.
10-Bit Graphics
Re: 10-Bit Graphics
I can't get this to return the values I think it should.
I am trying to plot a pixel with R-G-B 940-940-940
I am trying to plot a pixel with R-G-B 940-940-940
Code: Select all
img = CreateImage(1,100,100,24)
StartDrawing(ImageOutput(1))
Plot (50,50,RGB(940,940,940))
color = Red(Point(50,50))
Debug "Red "+Str(color)
color = Point(50,50)
color = Point(50,50)
StopDrawing()
Debug Red(color)
Debug Green(color)
Debug Blue(color)
Re: 10-Bit Graphics
The help states that RGB() works with values from 0 to 255, so this won't work. I don't say it's not possible in PureBasic to have 10 bit images, but it's at least not possible with the internal functions.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: 10-Bit Graphics
You are referring to 30bit depth images, not to 10bit.
And as we know, VGAs does not allow it.
And as we know, VGAs does not allow it.
Re: 10-Bit Graphics
10 bits per channel.You are referring to 30bit depth images, not to 10bit.
There is also 12 bpc.
https://www.datavideo.com/us/article/41 ... %208%2Dbit.
Re: 10-Bit Graphics
No, it's not supported and shouldn't by most OS'es, never out of the box except maybe on exotic and specialized systems (e.g. the camera taking the picture and a PC software for accessing it).
But "yes", you could also write your own image decoders but I suppose you would have "invisible" information loss because you'd have to convert it to a 24/32 bit RGB array which are PB's internal standard resolutions (I noticed on Windows that indexed/palletized 8 bit BMP's are loaded as 8 bit arrays, tho).
But "yes", you could also write your own image decoders but I suppose you would have "invisible" information loss because you'd have to convert it to a 24/32 bit RGB array which are PB's internal standard resolutions (I noticed on Windows that indexed/palletized 8 bit BMP's are loaded as 8 bit arrays, tho).
-
- Enthusiast
- Posts: 581
- Joined: Wed Sep 25, 2019 10:18 am
Re: 10-Bit Graphics
In the opposite way, I built a homemade system to manage only 2 bits per color channel.
The photographies got a particular aspect.
The color channel step were 0, 85, 170 and 255. The linear distance were (in my humble opinion) the best way to reduce the quantity of bits per channel.
From 0 to 42 => %00 => 0/255
From 43 to 127 => %01 => 85/255
From 128 to 212 => %10 => 170/255
From 213 to 255 => %11 => 255/255
But an other way consists in dividing the 256 value of a displayable color channel to four parts :
From 0 to 63,
From 64 to 127,
From 128 to 191, and
From 192 to 255.
That ever is the problem between dot values and range values.
In the first case, this forces extrem values : the most dark channels and the most enlightened channels are more accurate than the intermediate channel values during the 8bits->2bits converts, but the colors respect the linear distances equalities
In the second case, the color proportions are respected (however there are a break of 6 bits) but the contrast is lost (12%).
So, for a depth > 3*8 bits, I think there are only vectorized pictured which can be created, if (for ex) the 3*10 bits depth is not displayable.
I also think specific API is the way (actually). Let's note that compiler directives and prototypes can replace the native functions.
The photographies got a particular aspect.
The color channel step were 0, 85, 170 and 255. The linear distance were (in my humble opinion) the best way to reduce the quantity of bits per channel.
From 0 to 42 => %00 => 0/255
From 43 to 127 => %01 => 85/255
From 128 to 212 => %10 => 170/255
From 213 to 255 => %11 => 255/255
But an other way consists in dividing the 256 value of a displayable color channel to four parts :
From 0 to 63,
From 64 to 127,
From 128 to 191, and
From 192 to 255.
That ever is the problem between dot values and range values.
In the first case, this forces extrem values : the most dark channels and the most enlightened channels are more accurate than the intermediate channel values during the 8bits->2bits converts, but the colors respect the linear distances equalities
In the second case, the color proportions are respected (however there are a break of 6 bits) but the contrast is lost (12%).
So, for a depth > 3*8 bits, I think there are only vectorized pictured which can be created, if (for ex) the 3*10 bits depth is not displayable.
I also think specific API is the way (actually). Let's note that compiler directives and prototypes can replace the native functions.
Re: 10-Bit Graphics
I don't know if this works, maybe it inspires you for the project. I read that PNG and many other formats also support 10bits and higher per channel, but I don't know if it gets converted to 24/32 bits by the plugins when an image is loaded or if it fails.
Code: Select all
; RGB 30 bits
#Mask10Bit = 1023
#convert_to_24bit = 255.0 / 1023.0
#convert_to_30bit = 1023.0 / 255.0
Procedure Red_30b(color30bit.l)
ProcedureReturn color30bit & #Mask10Bit
EndProcedure
Procedure Green_30b(color30bit.l)
ProcedureReturn (color30bit>>10) & #Mask10Bit
EndProcedure
Procedure Blue_30b(color30bit.l)
ProcedureReturn (color30bit>>20) & #Mask10Bit
EndProcedure
Procedure RGB_30b(R.u,G.u,B.u)
ProcedureReturn (R & #Mask10Bit) | ((G & #Mask10Bit) <<10) | ((B & #Mask10Bit) <<20)
EndProcedure
Procedure convert_rgb_30_to_24(color30bit.l)
Protected R = (color30bit & #Mask10Bit)
Protected G = (color30bit>>10) & #Mask10Bit
Protected B = (color30bit>>20) & #Mask10Bit
ProcedureReturn RGB(R * #convert_to_24bit, G * #convert_to_24bit, B * #convert_to_24bit)
EndProcedure
Procedure convert_rgb_24_to_30(color24bit.l)
Protected R= (color24bit & $FF)
Protected G = (color24bit>>8) & $FF
Protected B = (color24bit>>16) & $FF
R * #convert_to_30bit
G * #convert_to_30bit
B * #convert_to_30bit
ProcedureReturn R | G<<10 | B<<20
EndProcedure
Debug LSet("",100,"-")
Debug "30 bit color"
Define color.l = RGB_30b(800,700,900)
Debug Red_30b(color)
Debug Green_30b(color)
Debug Blue_30b(color)
color = convert_rgb_30_to_24(color)
Debug LSet("",100,"-")
Debug "converted to 24bit"
Debug Red(color)
Debug Green(color)
Debug Blue(color)
color = convert_rgb_24_to_30(color)
Debug LSet("",100,"-")
Debug "converted back to 30bit"
Debug Red_30b(color)
Debug Green_30b(color)
Debug Blue_30b(color)