Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
131 user(s) are online (125 user(s) are browsing Forums)

Members: 0
Guests: 131

more...

Support us!

Headlines

 
  Register To Post  

ObtainBestPen()
Just popping in
Just popping in


See User information
RedPen=IGraphics->ObtainBestPen(DefaultPubScreen->ViewPort.ColorMap,0xFFFFFFFF,0x00000000,0x00000000,
        
OBP_Precision,                            PRECISION_GUI,
        
OBP_FailIfBad,                            FALSE,
    
TAG_END);


Do I really need to specify the alpha channel? Does it have any benefit to specify it? Will I get a more accurate color with/without it?

Go to top
Re: ObtainBestPen()
Not too shy to talk
Not too shy to talk


See User information

Where do you see an alpha channel? There is no way to specify an alpha channel. There is only red, green, blue, precision and fail if bad.


Go to top
Re: ObtainBestPen()
Home away from home
Home away from home


See User information
@mritter0
I think you only have to specify the alpha channel if you are directly specifying the drawing colour for OS4. As thomas says, pen-based colours shouldn't have anything to do with alpha channel.

Author of the PortablE programming language.
Go to top
Re: ObtainBestPen()
Just popping in
Just popping in


See User information
0xFFFFFFFF is not ARGB?

It's not the same as html/web based colors?

#FFFFFF = 0x00FFFFFF ?

Workbench Explorer - A better way to browse drawers
Go to top
Re: ObtainBestPen()
Home away from home
Home away from home


See User information
@mritter0

Quote:

0xFFFFFFFF is not ARGB?



No it's a left justified 32 bit fraction.

from autodocs:

R = red level (32 bit left justified fraction)
G = green level (32 bit left justified fraction)
B = blue level (32 bit left justified fraction)

if your 256 bit colour is r then

R = r + (r<<8) + (r<<16) + (r<<24)

see also the doc for setRGB32 et al


Quote:

It's not the same as html/web based colors?

#FFFFFF = 0x00FFFFFF ?



Be careful not to make mistake either when you need an ARGB colour do not set the A part to 00 set it to FF, else at some future point when alpha support is extended all your graphics wil disappear (applies mainly tro SetRPAttrs()




Go to top
Re: ObtainBestPen()
Home away from home
Home away from home


See User information
@broadblues Quote:
No it's a left justified 32 bit fraction.

from autodocs:

R = red level (32 bit left justified fraction)
G = green level (32 bit left justified fraction)
B = blue level (32 bit left justified fraction)
...
see also the doc for setRGB32 et al

I always found this really baffling. I mean it dates back to AmigaOS 1.x (edit: nope, it's actually 3.0) era: Why would they implement 96 bit (3*32 bit) colour depth - that's overkill even today (24 bits is pretty good, and 30 bits is about as good as it gets on consumer video formats.)

Quote:
Be careful not to make mistake either when you need an ARGB colour do not set the A part to 00 set it to FF, else at some future point when alpha support is extended all your graphics wil disappear (applies mainly tro SetRPAttrs()

Hmmm, I thought alpha-channel support was already widely used in OS4, certainly SetRPAttrs() already uses it. And so does MUI4 iirc.


Edited by ChrisH on 2016/10/20 22:14:26
Author of the PortablE programming language.
Go to top
Re: ObtainBestPen()
Home away from home
Home away from home


See User information
@ChrisH

Quote:


always found this really baffling. I mean it dates back to AmigaOS 1.x (edit: nope, it's actually 3.0) era: Why would they implement 96 bit (3*32 bit) colour depth - that's overkill even today (24 bits is pretty good, and 30 bits is about as good as it gets on consumer video formats.)



Honestly I don't know, it could be that using fractional values was more flexible when convert between different colours spaces, or it could just be they were overly optimitic about how long it would be before HDR displays would surface.

A 32 bit fraction also allows aribitray depth. Less than 8 bits as well as more than 8bits by that I mean converting from a 32 bit fraction to a 5bit depth (for a 15/16 screen) is more acurate then converting from an 8bit value.

For the real why you need someone who was "there"

Quote:

Hmmm, I thought alpha-channel support was already widely used in OS4, certainly SetRPAttrs() already uses it. And so does MUI4 iirc.


There is limited support IIUC, some things take the alpha value more things don't.

Go to top
Re: ObtainBestPen()
Just popping in
Just popping in


See User information
I totally see my poorly asked question. I still had HTML color codes on the brain.

Anyway, I made a little function to make things easier for myself.

int32 GreenPen=ObtainPenHex((STRPTR)"#00FF00");


int32
ObtainPenHex
(STRPTR HexValue)
{
    
TEXT                            value[5];
    
uint32                            rgb;

    
IUtility->SNPrintf(value,3,"%s",HexValue+1);
    
r=strtol(value,NULL,16);

    
IUtility->SNPrintf(value,3,"%s",HexValue+3);
    
g=strtol(value,NULL,16);

    
IUtility->SNPrintf(value,3,"%s",HexValue+5);
    
b=strtol(value,NULL,16);

    return(
IGraphics->ObtainBestPen(DefaultPubScreen->ViewPort.ColorMap,((r<<24) | (r<<16) | (r<<8) | r),(g<<24) | ((g<<16) | (g<<8) | g),((b<<24) | (b<<16) | (b<<8) | b),
        
OBP_Precision,                            PRECISION_GUI,
        
OBP_FailIfBad,                            FALSE,
    
TAG_END));
}


    
IGraphics->ReleasePen(DefaultPubScreen->ViewPort.ColorMap,BluePen);
    
BluePen=-1;


Workbench Explorer - A better way to browse drawers
Go to top
Re: ObtainBestPen()
Home away from home
Home away from home


See User information
ermm

may I suggest simply

htmlcolor = stroul(HexValue + 1,NULL,16);

r = (htmlcolor & 0xFF0000) >> 16;
g = (htmlcolor & 0x00FF00) >> 8;
b = (htmlcolor & 0x0000FF);

rather than all those SNPrintfs ?

maybe with abit of error chacking and format verification for good measure

Go to top
Re: ObtainBestPen()
Just popping in
Just popping in


See User information
@mritter0
or even:

int32 GreenPen=ObtainPenHex(0x00FF00);

int32
ObtainPenHex
(uint32 htmlColour)
{
    
uint32 rgb;

    
= ((htmlColour 0xFF0000) >> 16) * 0x01010101;
    
= ((htmlColour 0x00FF00) >> 8)  * 0x01010101;
    
= ((htmlColour 0x0000FF))       * 0x01010101;

    return(
IGraphics->ObtainBestPen(DefaultPubScreen->ViewPort.ColorMaprgb,
                                    
OBP_PrecisionPRECISION_GUI,
                                    
OBP_FailIfBadFALSE,
                                    
TAG_END)
    );
}

Go to top
Re: ObtainBestPen()
Just can't stay away
Just can't stay away


See User information
@mritter0

To make converting from 8-bit to 32-bit RGB components simpler you can define a macro for it like so:

#define RGB8to32(c) ((uint32)(c) * 0x01010101UL)

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project