Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Windows
(Moderators:
FPK
,
Tomas Hajny
) »
Drawing a Buffer on a Canvas
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
order of evaluation of ov...
by
440bx
[
Today
at 01:10:10 pm]
cors issue
by
Prakash
[
Today
at 01:06:58 pm]
Ouch: BioMorph Fractal (W...
by
Boleeman
[
Today
at 01:06:32 pm]
lazarus ide tstring list ...
by
paweld
[
Today
at 12:54:52 pm]
Lazarus Trunk won't insta...
by
madref
[
Today
at 12:00:20 pm]
What's wrong with TListBo...
by
jipété
[
Today
at 10:53:45 am]
Recursive Circles Type Fr...
by
Boleeman
[
Today
at 10:08:38 am]
Access MSSQL with Lazarus
by
luca
[
Today
at 09:55:00 am]
Why renaming must be done...
by
Thaddy
[
Today
at 09:06:16 am]
Little Red Riding Hood (t...
by
circular
[
Today
at 08:46:13 am]
Bitmap 16bit R5G6B5
by
circular
[
Today
at 08:43:34 am]
Cannot rebuild Lazarus af...
by
PierceNg
[
Today
at 03:44:47 am]
Toggle Form/Unit View by ...
by
Aruna
[
Today
at 02:21:42 am]
Dash documentation for La...
by
dbannon
[
Today
at 02:16:46 am]
[Solved] Rich Text Format...
by
dbannon
[
Today
at 02:04:29 am]
LazTTF2Vector - An Enhanc...
by
maurog
[
Today
at 12:49:07 am]
[SOLVED] Copy the content...
by
PascalDragon
[September 19, 2024, 09:48:10 pm]
Trying to show compile ti...
by
QEnnay
[September 19, 2024, 09:38:24 pm]
Compiler error when check...
by
PascalDragon
[September 19, 2024, 09:37:17 pm]
Office Automation (MSWORD...
by
totya
[September 19, 2024, 09:29:35 pm]
Str declaration
by
PascalDragon
[September 19, 2024, 09:29:14 pm]
How can I get help in the...
by
vfclists
[September 19, 2024, 09:26:16 pm]
[SOLVED] DBGRID | Picklis...
by
bourbon
[September 19, 2024, 08:49:29 pm]
TListView.OnChange Event ...
by
msintle
[September 19, 2024, 07:19:54 pm]
[SOLVED] LazReport / Free...
by
1HuntnMan
[September 19, 2024, 06:55:33 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Drawing a Buffer on a Canvas (Read 4265 times)
Key-Real
Sr. Member
Posts: 362
Drawing a Buffer on a Canvas
«
on:
April 30, 2021, 07:10:39 pm »
How to draw a Buffer on a Canvas?
for y:=0 to height-1 do
for x:=0 to width-1 do begin
gfxCanvas.pixels[x,y]:=getPixel(bitmap,x,y);
end;
is to slow...
ia there a fast way like move( bitmap.data, canvas.data, width*height); <- as Idea
Logged
Handoko
Hero Member
Posts: 5290
My goal: build my own game engine using Lazarus
Re: Drawing a Buffer on a Canvas
«
Reply #1 on:
April 30, 2021, 08:50:40 pm »
Don't use TCanvas, it is slow.
Almost all VGAs even those 20 years old integrated VGAs have some basic support of hardware accelerated OpenGL. Performing graphics using hardware accelerated functions is not only twice or thrice faster than the non-hardware accelerated TCanvas but it can be hundreds times faster or more.
Read more:
https://forum.lazarus.freepascal.org/index.php/topic,51687.msg379944.html#msg379944
But if you don't have time to learn a new framework, use
ScanLine
. It will point you to the address of a horizontal line of pixels, this works much faster.
In the link below there is a "
Get pixel color of an image
" demo showing how to use ScanLine.
https://wiki.freepascal.org/Portal:HowTo_Demos#Graphics
Logged
lucamar
Hero Member
Posts: 4219
Re: Drawing a Buffer on a Canvas
«
Reply #2 on:
April 30, 2021, 10:18:42 pm »
Note also that if your "bitmap" is some kind of TGraphic descendant, TCanvas has quite a lot of ways of drawing it or making it draw itself: CopyRect, Draw, StretchDraw, etc. most of which are usually "fast enough".
There's no need of copying it pixel by pixel.
Logged
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!)
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.
wp
Hero Member
Posts: 12305
Re: Drawing a Buffer on a Canvas
«
Reply #3 on:
April 30, 2021, 10:54:03 pm »
Why do we always have to guess so many details?
Assuming that gfxCanvas is a TCanvas and bitmap is a TBitmap or another descendant of TGraphic then this works:
Code: Pascal
[Select]
[+]
[-]
gfxCanas
.
Draw
(
0
,
0
,
bitmap
)
;
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Windows
(Moderators:
FPK
,
Tomas Hajny
) »
Drawing a Buffer on a Canvas
TinyPortal
© 2005-2018