|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed Sep 02, 2020 10:22 pm Post subject: Image Pixel Color Conversion |
|
|
When use, example:
Code: | for i = 0, 10 do
x = img.Picture.Bitmap.Canvas.getPixel(i,0)
print(x)
end
|
it returns values as MS Access color code, like:
3878183
3680804
3680804
3680804
3615011
3680804
3878183
3943976
3746597
3812390
3878183
Now, how to convert that values to RGB values, using CE Lua script?.
In VB, I can use, example:
Code: | Color.FromArgb(_img.getPixel(i, _img.Height - 1).ToArgb)) |
Any solutions? _________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Thu Sep 03, 2020 12:52 am Post subject: |
|
|
those are rgb colors (system colors are negative)
print using this
Code: |
print(string.format('%.8x',x))
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Thu Sep 03, 2020 11:15 am Post subject: |
|
|
Thanks DB, I try:
Code: | print(string.format('%.8x',x)) |
Those return hex color format?.
But how to port this as Lua script?
Code: | Color.FromArgb(_img.getPixel(i, _img.Height - 1).ToArgb)) |
I try:
Code: | function HEXtoRGB(hexArg)
hexArg = hexArg:gsub('#','')
if(string.len(hexArg) == 3) then
return tonumber('0x'..hexArg:sub(1,1)) * 17, tonumber('0x'..hexArg:sub(2,2)) * 17, tonumber('0x'..hexArg:sub(3,3)) * 17
elseif(string.len(hexArg) == 6) then
return tonumber('0x'..hexArg:sub(1,2)), tonumber('0x'..hexArg:sub(3,4)), tonumber('0x'..hexArg:sub(5,6))
else
return 0, 0, 0
end
end
function RGBtoHEX(redArg, greenArg, blueArg)
return string.format('%.2x%.2x%.2x', redArg, greenArg, blueArg)
end
--- try to apply, example:
imgSource.setPixel(i + 1, j + 1, HEXtoRGB(RGBtoHEX(_img.getPixel(i, j)))) |
Get return error : "bad argument #3 to 'format' (number expected, got nil)"
[/code] _________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Fri Sep 04, 2020 10:36 am Post subject: |
|
|
blue=value & 0xff
green=(value >> & 0xff
red=(value >>16) & 0xff _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|