How to do an InvertRect ?

The page is there:

https://msdn.microsoft.com/fr-fr/library/windows/desktop/dd145007(v=vs.85).aspx

Is it possible to use it with 2015-2017 (2018) Xojo versions (it use User32.lib and User32.dll), and if so, what can be its Xojo syntax.

Long time ago (more than 15 years), I used it, but I lost my archives, so…

Use: ? Invert Drop areas images (I actually use two images to do that when only one is enough).

From memory:

The InvertRect call is in User32

You get the hdc of the graphics using

TheGraphics.Handle(1)

The RECT will be a pointer to a memoryblock holding 4 LONGs (probably 32bit UINTs)
left, top, right, bottom

try something like:

Declare Function InvertRect Lib “User32” (ByVal hdc As Integer, mb as memoryblock) As Integer

Thanks Jeff, I will try it.

Use the TRANSFORM function… it is VERY FAST

myPic.RGBSurface.Transform map_invert
dim map_invert(255) as integer
for i=0 to 255
map_invert(i)=255-i
next i

Here are a few maps I created years a go for a Paint program I wrote

For i=0 To 255
//
// Sepia Map
//
Map_Sepia_R.Red(i)=i*0.393
Map_Sepia_R.Green(i)=i*0.769
Map_Sepia_R.Blue(i)=i*0.189
'
Map_Sepia_G.Red(i)=i*0.349
Map_Sepia_G.Green(i)=i*0.686
Map_Sepia_G.Blue(i)=i*0.168
'
Map_Sepia_B.Red(i)=i*0.272
Map_Sepia_B.Green(i)=i*0.534
Map_Sepia_B.Blue(i)=i*0.131
//
// Invert Colors
map_invert(i) = 255 - i
//
// 216 Websafe Colors
//
map_websafe216(i)=round(i/&h33)*&h33 ' 216 color WEBSAFE
//
// 64 Websafe Colors
//
map_websafe64(i)=round(i/&h55)*&h55 ' 64 color WEBSAFE
//
// Gray Scale
//
Map_Gray256.red(i)=i * 0.299
Map_Gray256.green(i)=i * 0.587
Map_Gray256.blue(i)=i * 0.114
//
'
Next i

Hi Dave,

Thank you for both answers.

I really love the Transform idea (not the answer of the question but A VALID ANSWER !)

Best of all, it works on Windows (tried on XP right now) and so certainy do the same on macOS (and Linux) !!!

OK: I was (still) am tired… I searched in the docs and found the (!) example there to be used near as is (!). It works fine (not like I wanted, bit gaves the expected result). I will let the night and be back by tomorrow morning to adjust the example as I want it.

Nota: there is an error in the code @ RGBSurface.Transform .
Line 2 miss a k in the konstant name.

I had that InvertRect in a memory case (in my brain) and I keep the idea, my brain was focussed to that idea :frowning: when a multipurpose solution was in the LR !!!.