 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Thu Aug 27, 2020 5:51 am Post subject: It need to be optimized to realize Gaussian blur with canvas |
|
|
This is an example written in ce7.1, where you need to create a form, an image, and several panels...
I need your help next.
First: I just want a black fuzzy background (I don't know the fuzzy algorithm)
Second: how to make all the controls display the fuzzy background together。
Code: | f.Color=0x0000DC
function setShadow(form,control,v,s) --form.repaint()
local L=control.Left+2
local T=control.Top+2
local W=control.Width
local H=control.Height
form.OnPaint=function()
--form.Canvas.Brush.Style=1
for j=1,v do
if f.color~=0x00 then
form.Canvas.Pen.Color=form.color-j*v*3
form.Canvas.Brush.Color=form.color-j*v*3
else
form.Canvas.Pen.Color=form.color+j*v*3
form.Canvas.Brush.Color=form.color+j*v*3
end
for i=1,s-j*2 do
form.Canvas.Pen.Width=i--i+W/2
form.Canvas.roundRect(L,T,L+W,T+H,0,0)
--form.Canvas.TextOut(L,T,'test')
end
end
end
form.repaint()
end
f.p1.visible=true
setShadow(f,f.p1,10,10)
for i=1,7 do
local p='p'..i
f[p].OnClick=function(sender)
f.color=sender.color
setShadow(f,f[p],10,10)
end
end
f.m.OnMouseDown=function(sender,button) f.dragNow() end
f.setLayeredAttributes(0xb4b4b4,250,3,3) |
Description: |
|
Filesize: |
696.3 KB |
Viewed: |
1228 Time(s) |

|
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Aug 28, 2020 12:59 pm Post subject: |
|
|
This is about Gaussian Blur implementation through the image in VB Net, I've done. Maybe the Gaussian Blur usage logic in the script will help. I try to port the script to CE Lua, but some part I don't know how to re-write in Lua.
VB Net script:
Code: |
Private Function ColourAvg(ByVal szAvgSize As Size, ByVal szfImageSize As SizeF, ByVal intX As Integer, ByVal intY As Integer) As Color
Dim arrlPixels As New ArrayList 'Host All Pixels
Dim x As Integer 'X Location
Dim y As Integer 'Y Location
Dim bmpBlurDest As Bitmap = picBlurDest.Image.Clone 'Image To Be Cloned
'Find Each Pixel's Colour And Add To ArrayList
For x = intX - CInt(szAvgSize.Width / 2) To intX + CInt(szAvgSize.Width / 2) 'Left To Right
For y = intY - CInt(szAvgSize.Height / 2) To intY + CInt(szAvgSize.Height / 2) 'Up To Down
If (x > 0 And x < szfImageSize.Width) And (y > 0 And y < szfImageSize.Height) Then 'If Not Out Of Bounds
arrlPixels.Add(bmpBlurDest.GetPixel(x, y)) 'Add To ArrayList
End If
Next
Next
Dim clrCurrColour As Color 'Current Colour
Dim intAlpha As Integer = 0 'Alpha Channel
Dim intRed As Integer = 0 'Red Channel
Dim intGreen As Integer = 0 'Green Channel
Dim intBlue As Integer = 0 'Blue Channel
For Each clrCurrColour In arrlPixels 'Loop Through Each Colour
'Store Each Colour
intAlpha += clrCurrColour.A
intRed += clrCurrColour.R
intGreen += clrCurrColour.G
intBlue += clrCurrColour.B
Next
' Return Average A, R, G, B
Return Color.FromArgb(intAlpha / arrlPixels.Count, intRed / arrlPixels.Count, intGreen / arrlPixels.Count, intBlue / arrlPixels.Count)
End Function
'Blur Sub
Private Sub GaussianBlur(ByVal blnAlphaEdges As Boolean, ByVal szBlurSize As Size)
Dim Y As Integer 'Y
Dim X As Integer 'X
Dim bmpBlurDest As Bitmap = picBlurDest.Image.Clone 'Clone Of Image
'Show Progress
lblProgress.Text = "Applying Gaussian Blur " & szBlurSize.ToString
prgBlurProgress.Maximum = bmpBlurDest.Height * bmpBlurDest.Width 'Set Max
prgBlurProgress.Minimum = 0 'Set Min
prgBlurProgress.Value = 0 'Initialize Value
'Loop Through Image
For Y = 0 To bmpBlurDest.Width - 1 'Top To Bottom
' Left To Right
For X = 0 To bmpBlurDest.Height - 1
If Not blnAlphaEdges Then 'AlphaEdges Not Chosen
bmpBlurDest.SetPixel(X, Y, ColourAvg(szBlurSize, bmpBlurDest.PhysicalDimension, X, Y)) 'Do Blur
ElseIf bmpBlurDest.GetPixel(X, Y).A <> 255 Then 'Alpha Is Not Set To 255
bmpBlurDest.SetPixel(X, Y, ColourAvg(szBlurSize, bmpBlurDest.PhysicalDimension, X, Y)) 'Do Blur
End If
prgBlurProgress.Value += 1 'Update Progress
Application.DoEvents() 'Ensure App Doesn't Hang
Next
Next
picBlurDest.Image = bmpBlurDest.Clone 'Update Blurred Image
bmpBlurDest.Dispose() 'Remove From Memory
End Sub
Private Sub btnBlur_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBlur.Click
GaussianBlur(chkAlphaEdges.Checked, New Size(8, 8)) 'Call Blur Function
End Sub
|
Tried ported to CE Lua script (Not finish yet)
Code: | if f then f.destroy() end
f = createForm()
f.Position = 'poScreenCenter'
f.setSize(352,290)
f.Caption = 'Gaussian Blur CE 7.1 Example'
picBlurSource = createImage(f)
picBlurSource.setSize(160,160)
picBlurSource.setPosition(12,12)
picBlurSource.Stretch = true
picBlurSource.Picture.loadFromStream(findTableFile('woman.jpg').Stream)
picBlurDest = createImage(f)
picBlurDest.setSize(160,160)
picBlurDest.setPosition(180,12)
picBlurDest.Stretch = true
picBlurDest.Picture.loadFromStream(findTableFile('woman.jpg').Stream)
btnBlur = createButton(f)
btnBlur.setSize(171,23)
btnBlur.setPosition(12,200)
btnBlur.Caption = 'Blur'
chkAlphaEdges = createCheckBox(f)
chkAlphaEdges.setPosition(210,202)
chkAlphaEdges.Caption = 'Enable Alpha Edges'
chkAlphaEdges.Checked = false
lblProgress = createLabel(f)
lblProgress.setPosition(12,232)
lblProgress.Caption = 'tes'
prgBlurProgress = createProgressBar(f)
prgBlurProgress.Left = 12
prgBlurProgress.Top = 250
prgBlurProgress.setSize(328, 23)
prgBlurProgress.Value = 0
prgBlurProgress.Step = 10
prgBlurProgress.Min = 0
prgBlurProgress.Max = 100
--------------------------------------------------------------
function ColourAvg(szAvgSize, szfImageSize, intX, intY)
local arrlPixels = {}
local x, y
local bmpBlurDest = picBlurDest.Picture.Bitmap
for x = intX - (szAvgSize.Width / 2), intX + (szAvgSize.Width / 2) do
for y = intY - (szAvgSize.Height / 2), intY + (szAvgSize.Height / 2) do
if (x > 0 and x < szfImageSize.Width) and (y > 0 and y < szfImageSize.Height) then
table.insert(arrlPixels, bmpBlurDest.getPixel(x, y))
end
end
end
-- not ported to Lua yet
local clrCurrColour
local intAlpha = 0
local intRed = 0
local intGreen = 0
local intBlue = 0
for clrCurrColour in arrlPixels do
intAlpha = intAlpha + clrCurrColour.A
intRed = intRed + clrCurrColour.R
intGreen = intGreen + clrCurrColour.G
intBlue = intBlue + clrCurrColour.B
end
-- not ported to Lua yet
return Color.FromArgb(intAlpha / arrlPixels.Count, intRed / arrlPixels.Count,
intGreen / arrlPixels.Count, intBlue / arrlPixels.Count)
end
function GaussianBlur(blnAlphaEdges, szBlurSize)
local X, Y
local bmpBlurDest = picBlurDest.Picture.Bitmap
lblProgress.Text = "Applying Gaussian Blur "..tostring(szBlurSize)
prgBlurProgress.Maximum = bmpBlurDest.Height * bmpBlurDest.Width
prgBlurProgress.Minimum = 0
prgBlurProgress.Value = 0
for Y = 0, bmpBlurDest.Width - 1 do
for X = 0, bmpBlurDest.Height - 1 do
if not blnAlphaEdges then
bmpBlurDest.setPixel(X, Y, ColourAvg(szBlurSize, bmpBlurDest.PhysicalDimension, X, Y))
elseif bmpBlurDest.getPixel(X, Y).A ~= 255 then
bmpBlurDest.setPixel(X, Y, ColourAvg(szBlurSize, bmpBlurDest.PhysicalDimension, X, Y))
end
prgBlurProgress.Value = prgBlurProgress.Value + 1
end
end
picBlurDest.Picture = bmpBlurDest.Bitmap
end
function btnBlur_Click(sender, e)
GaussianBlur(chkAlphaEdges.Checked, 8, 8)
end
-------------------------------------------------------
f.Show()
btnBlur.OnClick = btnBlur_Click |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Sat Aug 29, 2020 1:57 am Post subject: |
|
|
Corroder wrote: | Tried ported to CE Lua script (Not finish yet) | There are errors on lines 49 and 90, trying to call a null value
|
|
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
|
|