Same RGB color gives different results out/inside HtmlViewer

Hi,

I’m trying to make a HtmlViewer “transparent” by using the same background color for both window and HtmlViewer.

I’m changing the HtmlViewer background color by using “background-color: rgb(red, green, blue);”, red/green/blue being the corresponding window background color RGB values.

The HtmlViewer Background Color

  • is exactly the same as the window background color when running on Windows (7 and 10)
  • is different on macOS High Sierra, small or obvious differences, depending on the color

I’m using WebKit for both Windows and macOS.
Xojo 2017r3, desktop app.

I need a solution 100% Xojo here, no plugins allowed (declares ok).
I don’t find any info about this strange webkit behavior.

Small demo project available here: just load, run and click the small rectangle to see what happens.

Does someone know how to solve this ? Or to “convert” the RGB values to get the same color within HtmlViewer ?

All ideas are welcome.

Thanks,

Olivier

The issue is that Safari/Webkit is doing colorspace management on macOS but not Windows.

See https://forum.xojo.com/39621-mac-windows-color-inconsistencies

Hi Michael,

Thanks. I’d seen this post but this requires MBS plugins, which I have, but can’t use in this project.
Any idea how to get this result using declares ?

Regards,

Try using red color &hFF0000 and post the result.

Hi Asis,

Thanks for helping but I don’t see what kind of results you want.
All I know is that the window and the htmlviewer have the same rgb color and that the rendering is diff. on a Mac.
You can try with the small demo project from my 1st post.

My main OS is Linux and I don’t have access to Mac. Works fine here on Linux. Forget about my last comment :D.

You can always try changing the colorspace on your machine to standard unadjusted RGB
But you have no control over your user’s machines.

[quote=367928:@Olivier Colard]Hi Michael,

Thanks. I’d seen this post but this requires MBS plugins, which I have, but can’t use in this project.
Any idea how to get this result using declares ?

Regards,[/quote]

Most things that MBS does can be done using declares. It’s just a lot more difficult, which is why Christian makes the money he does. :slight_smile:

That being said, if you want to write this using Declares, you basically need to follow the same code.

Check out the http://developer.xojo.com/declare example which show you how to get a class pointer, which is the first step.

So the first steps using MBS:

dim screen as NSScreenMBS = NSScreenMBS.mainScreen
dim screenColorSpace as NSColorSpaceMBS = screen.colorSpace

in pure Xojo code would be

' Gets a reference to a class
Declare Function NSClassFromString Lib "Foundation" (classname As CFStringRef) As Ptr

' get the screen class
dim screenPtr as Ptr = NSClassFromString("NSScreen")

' get the colorSpace from the screen
Declare Function NSScreenColorSpace Lib "AppKit" (classPtr as Ptr) As Ptr
dim screenColorSpacePtr as Ptr = NSScreenColorSpace(screenPtr)

The rest is left as an exercise.

Oliver.

Safari is assuming your RGB values are sRGB (the standard color space) and is likely converting them from sRGB to the user’s monitor profile, resulting in a close color appearance on the monitor to the original sRGB color.

How does this help you? though to say.

As mentioned above, if you treat your RGB value as sRGB and convert through the sRGB profile to the monitor profile, you should probably come up with an RGB value that you can use outside of the HTML viewer. That’s a bit tough and might be unnecessary.

What would be easier, is to get RGB in the browser that is not color managed. Things are constantly changing in the web world. What I would recommend trying now is specifying your background color using an image that has no profile embedded. I’m not certain that this will work but it’s worth a try.

There’s a bit of a write-up of the state of the art here

Let us know how it goes…