| View previous topic :: View next topic |
| Author |
Message |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Wed Sep 30, 2020 5:32 am Post subject: Load Bitmap To Paint Box Canvas |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25806 Location: The netherlands
|
Posted: Wed Sep 30, 2020 7:21 am Post subject: |
|
|
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 |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Wed Sep 30, 2020 7:35 am Post subject: |
|
|
| 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 |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25806 Location: The netherlands
|
Posted: Wed Sep 30, 2020 7:46 am Post subject: |
|
|
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 |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Wed Sep 30, 2020 8:07 am Post subject: |
|
|
Yes, It works as well
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| Back to top |
|
 |
|