Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
(Moderator:
Ask
) »
How do I read the RGBA values of a pixel from a surface or texture with SDL2?
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
IRC channel
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
Access violation when re-...
by
TRon
[
Today
at 07:37:31 pm]
[SOLVED] assembler name i...
by
TRon
[
Today
at 07:26:33 pm]
How to: create DLL file f...
by
440bx
[
Today
at 07:19:45 pm]
Database standards OR Am ...
by
wpflum
[
Today
at 07:18:20 pm]
what to do if my target M...
by
Laksen
[
Today
at 07:04:34 pm]
A fairly simple sound sol...
by
KodeZwerg
[
Today
at 07:01:52 pm]
Step-into the field sette...
by
Martin_fr
[
Today
at 06:54:19 pm]
[Fun Fact] PNG and Micros...
by
Ten_Mile_Hike
[
Today
at 06:24:19 pm]
Demoscene The Champs Crac...
by
KodeZwerg
[
Today
at 06:20:31 pm]
HTTP/2+HTTP/1.1+WebSocket...
by
iLya2IK
[
Today
at 06:14:30 pm]
I just released a commerc...
by
Eugene Loza
[
Today
at 05:57:11 pm]
Improvement of TFPTimerTh...
by
AlexTP
[
Today
at 05:56:38 pm]
Arabic text, problem on L...
by
nouzi
[
Today
at 05:21:27 pm]
WKWebView takeSnapshot
by
MISV
[
Today
at 04:53:41 pm]
Question for people who h...
by
VisualLab
[
Today
at 04:46:24 pm]
Slow copying of small str...
by
Nitorami
[
Today
at 04:41:52 pm]
location of non visual co...
by
gerardus
[
Today
at 04:16:44 pm]
How to get along with the...
by
BrassGear
[
Today
at 03:24:10 pm]
Assign (textfile) not com...
by
Thaddy
[
Today
at 03:16:52 pm]
[Solved] Find child contr...
by
Handoko
[
Today
at 03:01:47 pm]
Linux Workspaces -- StayO...
by
QEnnay
[
Today
at 02:40:24 pm]
lazarus-project_3.2.0-0_a...
by
Edgardo M. López
[
Today
at 02:29:07 pm]
Azure sql database will n...
by
wpflum
[
Today
at 02:18:43 pm]
create system unit from s...
by
KodeZwerg
[
Today
at 02:02:25 pm]
Spiral of Theodorus: Reve...
by
Roland57
[
Today
at 01:24:14 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How do I read the RGBA values of a pixel from a surface or texture with SDL2? (Read 2621 times)
semichaud1
New Member
Posts: 38
How do I read the RGBA values of a pixel from a surface or texture with SDL2?
«
on:
December 01, 2019, 05:26:37 pm »
Hi,
How do I read the RGBA values of a specific pixel, at given coordinates x and y, from a surface or texture with SDL2 in Free Pascal?
Thanks.
Logged
piXelicidio
Newbie
Posts: 3
Re: How do I read the RGBA values of a pixel from a surface or texture with SDL2?
«
Reply #1 on:
December 17, 2019, 02:45:38 pm »
Hi, you can't or shouldn't read pixels from a texture because its on GPU memory.
Only from surfaces:
When you create the surface with (
https://wiki.libsdl.org/SDL_CreateRGBSurface
) maybe with 32 bits in the deph parameter.
Then it returns an structure (record):
https://wiki.libsdl.org/SDL_Surface
There you can get and access anytime the "pixels" pointer.
From that record you need also pitch to make your custom getpixel and setpixel.
Logged
metis
Sr. Member
Posts: 300
Re: How do I read the RGBA values of a pixel from a surface or texture with SDL2?
«
Reply #2 on:
December 20, 2019, 06:09:09 pm »
@semichaud1
and then try it with
SDL_GetDisplayDPI(...); // Get diagonal, horizontal, vertical DPI
and
SDL_GetRGBA(...); // Get the Pixel's RGBA-Values
Logged
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus =
FFPlay4Laz
+
FFGrab4Laz
+ FFInfo4Laz
metis
Sr. Member
Posts: 300
Re: How do I read the RGBA values of a pixel from a surface or texture with SDL2?
«
Reply #3 on:
May 30, 2020, 04:49:46 pm »
@semichaud1
with
'SDL_RenderReadPixels()'
you may get the Pixels from a Texture w/o creating a Surface in Your Code, see:
https://discourse.libsdl.org/t/most-efficient-way-of-getting-render-pixels/27581
.
Logged
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus =
FFPlay4Laz
+
FFGrab4Laz
+ FFInfo4Laz
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
(Moderator:
Ask
) »
How do I read the RGBA values of a pixel from a surface or texture with SDL2?
TinyPortal
© 2005-2018