Transparency: how to prevent?

I’m creating a picture in a listbox’s DragRow event. This is then applied as the DragPicture:

p = new Picture (500, 65)
g = p.Graphics
g.Transparency = 0.0

// text & other drawing here

drag.DragPicture = p

The picture thus created has some transparency (i.e., it is translucent) which I’d like to remove (it’s distracting). Further, under WIndows, the drag-picture is so translucent as to be almost invisible - much worse.

So: how can I get rid of it?

1 Like

So: how can I get rid of it?

System Preferences > Accessibility > Display > Reduce Transparency

It’s applied by the system after you draw your picture.

Already set here under Sonoma.

I want to be able to this in code; the effect under Windows is to make the drag-picture essentially unuseable.

You may need to change the pixel colors to have less transparency.

or try:

// yourOriginalPicture
// p must be same size as original picture for best results.

p = new Picture (500, 65)
g = p.Graphics
g.Transparency = 0.0 // 0.0 is opaque
g.drawPicture(yourOriginalPicture, 0, 0) // redraws picture but this time the Transparency will be applied.

// p is now with re-applied transparency. May or may not have the effect you need. 

https://documentation.xojo.com/api/graphics/graphics.html#graphics-transparency

I don’t have an original picture. Do you mean I should do this:

p = new Picture (500, 65)
g = p.Graphics

// text & other drawing here, then ...

p1 = new Picture (500, 65)
g1 = p1.Graphics
g1.Transparency = 0.0
g1.drawPicture (p, 0, 0)

drag.DragPicture = p1

Edit: tried this - no effect at all.

As far as I know, nothing we do to the Xojo picture can help. The system is applying the effect after we draw the picture in Xojo.

Ah. In my Win-10 VM I did try turning off transparency in the (system) Settings but that had no effect either.

Does it make a difference if you specify the depth? If I recall

new picture(500, 65) // picture with transparancy
new picture(500, 65, 32) // picture is opaque by default

I don’t know if that applies here or not.

you may need to use graphics class, assign as color and fill the rectangle for the picture with an opaque color.

1 Like

I’ll give that a whirl, @Tim_Hare , but not til tomorrow as it’s now bedtime. But according to the docs, the third arg to the constructor is a set of bitmaps, not a depth. Not that I’ve been able to find out from the docs what a bimap is anyway. Depth is mentioned but only vaguely.

If you mean this effect
https://tracker.xojo.com/xojoinc/xojo/-/issues/56328

unfortunately there is nothing you can do about that in code (except possibly via declares).

On Windows this transparency (plus gradient) is so bad that the drag picture is almost invisible. I’ll be able to see how bad it is under WIn-11 next week.

Seems to be similar

Edit: makes no difference, sorry to say (tested with macOS and Win-10 in a VM).

TMy drag-picture looks similar to the bottom-right portion of your image (and that’s the most visible part of my drag-picture. The least visible part is gone altogether).

I fear you can’t do anything 'bout it. See what i see on Win10/64:

Hmmm. More and more curious. I remembered that I now have four different drag/drop situations implemented in my app, and it belatedly occurred to me to check how the three that have been implemented for some time perform under Windows. The odd thing is that those three have no transparency issue under Windows. They all create a new picture, draw into it using various graphics methods, then assign it to the drag as its DragPicture. Only the fourth one, which does the same sorts of actions, has a problem. So far, looking through the code for all four, can’t see any significant difference in the actions taken.

OK, pinned it down. It struck me that the failing picture is rather larger than the working ones, at 500x65 instead of around 200x25. Reducing to those dimensions gave me under Windows a picture looking just like the ones under macOS or Linux.

Further testing allowed me to get to 300x65. Going to 301x65 - back to transparency and a gradient across the drag picture. Here are some screenshots:

At 300 x 65:

and at 301 x 65:

The drag picture in the second image is barely visible. Perhaps this makes sense to someone.

No, but it’s not Xojo specific. See here f.e.: windows - Drag and drop custom image: at what size does the system automatically fade the outer edge? - Stack Overflow

I’ve read that this is controlled by the Windows OS and it’s afaik undocumented behaviour. But it can be changed for Win32 Apps using the IDragSourceHelper Interface.

I’ve talked to ChatGPT regarding this effect and tried to find documentations for it, but even ChatGPT wrote:

Unfortunately, there doesn’t seem to be official documentation from Microsoft explaining this limitation in detail. However, many developers have observed this behavior and discussed it in forums, suggesting it’s an intentional design to maintain system stability.

If you’re working with drag-and-drop in your application, keeping drag images within the 300x300 pixel limit is the safest approach to avoid transparency issues.

Thank you. At least I know what’s going on.

1 Like