AnonMiraj / fig

FIG (Fortran Intuitive Graphics)
MIT License
22 stars 2 forks source link

Convert integers to RGB values #9

Closed johandweber closed 2 months ago

johandweber commented 2 months ago

Hallo,

i have added a method int_to_RGB that is able to convert the integers used for the canvas to RBG values to rgb.f90. Additionally, I have added a test program for int_to_RBG and RGB_to_int.

This is mainly preparative work for reading ppm files.

AnonMiraj commented 2 months ago

Hello, I've noticed a small mistake. Why do you use ishft if ibits already does that and provides the correct RGB values? shouldn't it be something like this?


       color%a = ibits(rgb_int,24, 8)
       color%b = ibits(rgb_int,16,8)
       color%g = ibits(rgb_int,8, 8)
       color%r = ibits(rgb_int,0,8)       
johandweber commented 2 months ago

Thanks! I have not known that ibits already returns right-adjusted values. I have now corrected rgb.f90 accordingly.

AnonMiraj commented 2 months ago

Okay, everything looks good to me. Thank you for the PR.