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
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Interesting video
by
440bx
[
Today
at 02:42:30 am]
Message CM_ShowingChanged...
by
LeP
[
Today
at 02:13:51 am]
Fast Canvas Library V1.05...
by
Gigatron
[
Today
at 01:48:44 am]
[SOLVED]Program experienc...
by
Cainnech
[
Today
at 12:19:17 am]
Single and Double, Conver...
by
kupferstecher
[
Today
at 12:12:11 am]
TATTabs - how to stop a 3...
by
bobonwhidbey
[
Today
at 12:03:15 am]
New version of LazMapView...
by
wp
[June 12, 2026, 10:56:43 pm]
If FileExists(
by
Bart
[June 12, 2026, 10:39:03 pm]
Which Control should I us...
by
J-G
[June 12, 2026, 08:36:07 pm]
If you are looking for Wi...
by
avra
[June 12, 2026, 07:37:10 pm]
SynEdit theme
by
Martin_fr
[June 12, 2026, 07:35:26 pm]
Can /my/ AI help me with ...
by
microxa
[June 12, 2026, 04:26:18 pm]
Lazarus Bugfix Release 4....
by
Martin_fr
[June 12, 2026, 03:57:39 pm]
Testing with 3.2.4 prepar...
by
Martin_fr
[June 12, 2026, 03:50:17 pm]
IndySecOpenSSL is now ava...
by
LeP
[June 12, 2026, 10:22:50 am]
TDWEdit
by
Ed78z
[June 12, 2026, 10:20:58 am]
Strange Behaviour at Runt...
by
andrew Bubble
[June 12, 2026, 09:54:40 am]
FPC Debug mode releases [...
by
Martin_fr
[June 12, 2026, 09:22:25 am]
Implementing an Elo ratin...
by
paule32
[June 12, 2026, 08:43:20 am]
Death of the Power User
by
wp
[June 12, 2026, 01:29:18 am]
how to add a ForEach call...
by
mas steindorff
[June 11, 2026, 11:42:24 pm]
How to define a type of ...
by
PascalDragon
[June 11, 2026, 09:24:45 pm]
Gitlab site history date.
by
Martin_fr
[June 11, 2026, 08:46:17 pm]
Arkanoid
by
lazarusprogrammer
[June 11, 2026, 08:14:21 pm]
[New Component] ExtTabCtr...
by
d7_2_laz
[June 11, 2026, 05:01:49 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Drawing a Buffer on a Canvas (Read 4972 times)
Key-Real
Sr. Member
Posts: 404
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
Demo Scene
,
FlyTracker
,
FPC for PlayStation 1
,
my Repos
Handoko
Hero Member
Posts: 5546
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: 4217
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: 13565
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