Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon Sep 07, 2020 2:59 pm Post subject: CE Trainer Design Alphablend Example |
|
|
Just bored, so here is an alpha blending (opacity) example:
Note : that is free to add your own images and credit going to mgr.inz.Player and DarkByte
Code: | function TBlendFunction(SourceConstantAlpha)
return byteTableToDword({0,0,SourceConstantAlpha,1})
end
function getCanvasHandle(canvas)
canvas.getPixel(0,0)
return readPointerLocal(userDataToInteger(canvas)+0xc8)
end
function setAlphaBlend(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction)
return executeCodeLocalEx("msimg32.AlphaBlend",
hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction)
end
note = [[
hdcDest = Handle to the destination device context.
nXOriginDest = Specifies the x-coordinate,
in logical units, of the upper-left corner of the destination rectangle.
nYOriginDest = Specifies the y-coordinate,
in logical units, of the upper-left corner of the destination rectangle.
nWidthDest = Specifies the width,
in logical units, of the destination rectangle.
nHeightDest = Specifies the height, in logical units, of the destination rectangle.
hdcSrc = Handle to the source device context.
nXOriginSrc = Specifies the x-coordinate,
in logical units, of the upper-left corner of the source rectangle.
nYOriginSrc = Specifies the y-coordinate,
in logical units, of the upper-left corner of the source rectangle.
nWidthSrc = Specifies the width,
in logical units, of the source rectangle.
nHeightSrc = Specifies the height,
in logical units, of the source rectangle.
blendFunction = Specifies the alpha-blending function for source and destination bitmaps,
a global alpha value to be applied to the entire source bitmap,
and format information for the source bitmap.
The source and destination blend functions are currently
limited to AC_SRC_OVER.
]]
function setOpacity(src, alpha, tblfile)
if pngImage or tmpImage then
pngImage.destroy()
tmpImage.destroy()
end
pngImage = createImage(nil)
ch = string.sub(tblfile, -4)
if ch == '.jpg' or ch == '.JPG' or ch == '.Jpg' then
pngImage.Picture.Jpeg.loadFromStream(findTableFile(tblfile).Stream)
else
pngImage.Picture.PNG.loadFromStream(findTableFile(tblfile).Stream)
end
tmpImage = createImage(nil)
local width = pngImage.Picture.Bitmap.Width
local height = pngImage.Picture.Bitmap.Height
tmpImage.Picture.Bitmap.PixelFormat = pf32bit
tmpImage.Picture.Bitmap.Width = width
tmpImage.Picture.Bitmap.Height = height
setAlphaBlend(getCanvasHandle(tmpImage.Picture.Bitmap.Canvas), 0, 0, width, height,
getCanvasHandle(pngImage.Picture.Bitmap.Canvas), 0, 0, width, height,
TBlendFunction(alpha))
src.Picture.assign(tmpImage.Picture)
src.repaint()
pngImage.destroy()
tmpImage.destroy()
end
function obj_click()
-- do something, example:
shellExecute('https://www.youtube.com/?hl=id&gl=ID')
end
-----------------------------------------------------------------------
if f then f.destroy() end
f = createForm()
f.setSize(450,250)
f.Position = 'poScreenCenter'
f.Caption = 'CE Trainer Art Design Example'
BackgroundBMP = createImage(f)
BackgroundBMP.Picture.loadFromStream(findTableFile('images.jpg').Stream)
BackgroundBMP.Align = 'alClient'
BackgroundBMP.Stretch = true
img1 = createImage(f)
img1.setSize(350,230)
img1.setPosition(30,10)
img1.stretch = true
img1.Picture.loadFromStream(findTableFile('truck.jpg').stream)
img1.OnMouseDown = function() f.dragNow() end
img2 = createImage(f)
img2.setSize(100,70)
img2.setPosition(330,25)
img2.stretch = true
img2.Picture.loadFromStream(findTableFile('btn1.png').stream)
img2.Cursor = -21
pb2=createPaintBox(f)
pb2.Left = 100
pb2.Top = 100
pb2.Width = 330
pb2.Heigth = 20
pb=createPaintBox(f)
pb.Left = 100
pb.Top = 100
pb.Width = 330
pb.Heigth = 20
pb2.OnPaint = function()
local rect1={}
rect1.Left=0
rect1.Top=0
rect1.Right=pb2.Width
rect1.Bottom=pb2.Height
pb2.Canvas.Font.Size = 36
pb2.Canvas.Font.Name = 'Arial'
pb2.Canvas.Font.Style = 'fsItalic'
pb2.Canvas.Font.Color = 5855577
pb2.Canvas.textRect(rect1,14,22,'Cheat Engine')
end
pb.OnPaint = function()
local rect={}
rect.Left=0
rect.Top=0
rect.Right=pb.Width
rect.Bottom=pb.Height
pb.Canvas.Font.Size = 34
pb.Canvas.Font.Name = 'Arial'
pb.Canvas.Font.Style = 'fsBold'
pb.Canvas.Font.Color = 0xffffff
pb.Canvas.textRect(rect,15,30,'Cheat Engine')
end
f.Show()
setOpacity(img1, 150, 'truck.jpg')
processMessages()
setOpacity(img2, 200, 'btn1.png')
img2.OnClick = obj_click |
Result as attached picture
Description: |
|
Filesize: |
34.3 KB |
Viewed: |
765 Time(s) |
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|