Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Load Bitmap To Paint Box Canvas

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Sep 30, 2020 5:32 am    Post subject: Load Bitmap To Paint Box Canvas Reply with quote

I try:

Code:

function createScrollBox(Parent)
local box = createComponentClass('TScrollBox', Parent)
 box.Parent = Parent
 return box
end

if fm then fm.destroy() end
fm = createForm()
fm.setSize(588, 390)

CanvasScroller = createScrollBox(fm)
CanvasScroller.Left = 9
CanvasScroller.Height = 272
CanvasScroller.Top = 94
CanvasScroller.Width = 554
CanvasScroller.Color =    16777215
CanvasScroller.HorzScrollBar.Tracking = true
CanvasScroller.HorzScrollBar.Page = 268
CanvasScroller.HorzScrollBar.Range = 550
CanvasScroller.HorzScrollBar.Position = 0
CanvasScroller.VertScrollBar.Tracking = true
CanvasScroller.VertScrollBar.Page = 10
CanvasScroller.VertScrollBar.Range = 200
CanvasScroller.VertScrollBar.Position = 0
CanvasScroller.Anchors = '[akTop, akLeft, akRight, akBottom]'
CanvasScroller.ClientHeight = 268
CanvasScroller.ClientWidth = 550
CanvasScroller.ParentColor = false

MyCanvas = createPaintBox(CanvasScroller)
MyCanvas.Left = 0
MyCanvas.Top = 0
MyCanvas.Height = 270
MyCanvas.Width = 550
MyCanvas.ParentColor = false

function MyCanvasPaint(sender)
 if MyCanvas.Width ~= paintbmp.Width then
    MyCanvas.Width = paintbmp.Width
    return
  end
 if MyCanvas.Height ~= paintbmp.Height then
    MyCanvas.Height = paintbmp.Height
    return
  end
  MyCanvas.OnPaint = function()
  MyCanvas.Canvas.Clear()
  MyCanvas.Canvas.draw(0, 0, paintbmp)
end


function setNew(sender)
 if paintbmp ~= nil then paintbmp.Destroy() end
 paintbmp = createBitmap()
 paintbmp.Width = getScreenWidth()
 paintbmp.Height = getScreenHeight()
 paintbmp.Canvas.FillRect(0,0, paintbmp.Width, paintbmp.Height)
 paintbmp.Canvas.Brush.Style = 1
 MyCanvas.Canvas.Brush.Style = 1
 MyCanvasPaint(sender)
end

fm.Show()
setNew(sender)
paintbmp.LoadFromFile('D:\\test.bmp')
MyCanvasPaint(sender)


1. Image Bitmap not draw to paintbox canvas (the image is bmp format)

2. How to load other image format such as png, jpg, etc?. Is by change ceateBitmap to createImage and then draw the picture bitmap to paintbox canvas?.

How do this thing properly?

EDIT:
This is work for bmp image format only

Code:
function MyCanvasPaint(sender)
 if MyCanvas.Width ~= paintbmp.Width then
    MyCanvas.Width = paintbmp.Width
    return
  end
 if MyCanvas.Height ~= paintbmp.Height then
    MyCanvas.Height = paintbmp.Height
    return
  end
end

function newProject(sender)
 if paintbmp ~= nil then paintbmp.Destroy() end
    paintbmp = createBitmap(self)
    paintbmp.PixelFormat = pf32bit
    paintbmp.Width = getScreenWidth()
    paintbmp.Height = getScreenHeight()
    paintbmp.Canvas.FillRect(0,0, paintbmp.Width, paintbmp.Height)
    paintbmp.Canvas.Brush.Style = 0
    MyCanvas.Canvas.Brush.Style = 0
    MyCanvasPaint(sender)
end

fm.Show()
newProject(sender)
paintbmp.LoadFromFile('D:\\woman.bmp')

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25806
Location: The netherlands

PostPosted: Wed Sep 30, 2020 7:21 am    Post subject: Reply with quote

change MyCanvasPaint to
Code:

function MyCanvasPaint(sender)
 if MyCanvas.Width ~= paintbmp.Width then
    MyCanvas.Width = paintbmp.Width
  end
 if MyCanvas.Height ~= paintbmp.Height then
    MyCanvas.Height = paintbmp.Height
  end
end


and replace createBitmap with createPNG to load a png

_________________
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
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Sep 30, 2020 7:35 am    Post subject: Reply with quote

Dark Byte wrote:
change MyCanvasPaint to
Code:

function MyCanvasPaint(sender)
 if MyCanvas.Width ~= paintbmp.Width then
    MyCanvas.Width = paintbmp.Width
  end
 if MyCanvas.Height ~= paintbmp.Height then
    MyCanvas.Height = paintbmp.Height
  end
end


and replace createBitmap with createPNG to load a png


Thanks DB for the answer.

I have change createBitmap() to createImage(self), so that allow to load any type image formats.

Code:
function MyCanvasPaint(sender)
 if MyCanvas.Width ~= paintbmp.Width then
    MyCanvas.Width = paintbmp.Width
    return
  end
 if MyCanvas.Height ~= paintbmp.Height then
    MyCanvas.Height = paintbmp.Height
    return
  end
   MyCanvas.Canvas.Clear()
   MyCanvas.Canvas.draw(0, 0, paintbmp.Picture.Bitmap)
end

function newProject(sender)
 if paintbmp ~= nil then paintbmp.Destroy() end
    paintbmp = createImage(self)
    paintbmp.Width = getScreenWidth()
    paintbmp.Height = getScreenHeight()
    paintbmp.Picture.Bitmap.Canvas.FillRect(0,0, paintbmp.Width, paintbmp.Height)
    paintbmp.Picture.Bitmap.Canvas.Brush.Style = 0
    MyCanvas.Canvas.Brush.Style = 0
    MyCanvasPaint(sender)
end

fm.Show()
MyCanvas.OnPaint = MyCanvasPaint
paintbmp.Picture.LoadFromFile('D:\\test.jpg')

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25806
Location: The netherlands

PostPosted: Wed Sep 30, 2020 7:46 am    Post subject: Reply with quote

createPicture might work as well
_________________
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
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Sep 30, 2020 8:07 am    Post subject: Reply with quote

Yes, It works as well
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites