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
a Unit problem?
by
TRon
[
Today
at 12:51:57 pm]
Any upgrades to fpWeb pag...
by
marcov
[
Today
at 12:50:25 pm]
Complex package installat...
by
JonBondy
[
Today
at 12:48:28 pm]
Help needed with Cairo / ...
by
Roland57
[
Today
at 12:25:16 pm]
JEDI error but unit compi...
by
Roland57
[
Today
at 11:50:11 am]
Using KeyPress event, how...
by
Bart
[
Today
at 11:32:53 am]
Configure JCF messages
by
DomingoGP
[
Today
at 11:26:55 am]
IDE instability on Raspbe...
by
rvk
[
Today
at 10:37:14 am]
Boleeman's projects are p...
by
AlexTP
[
Today
at 10:18:04 am]
Understanding and adjusti...
by
circular
[
Today
at 09:55:30 am]
Your best UI design - con...
by
circular
[
Today
at 09:36:11 am]
ZeosDBO and querys using ...
by
Zvoni
[
Today
at 09:27:17 am]
STARS with line border st...
by
Boleeman
[
Today
at 09:13:29 am]
Zeos components. Had to c...
by
dbannon
[
Today
at 07:26:11 am]
A button require administ...
by
Fibonacci
[
Today
at 05:57:21 am]
How to detect one externa...
by
d2010
[
Today
at 12:24:32 am]
Center Lost Window featur...
by
Tony Stone
[
Today
at 12:06:16 am]
Controlling the behavior ...
by
wp
[March 27, 2024, 10:43:40 pm]
A "leisure" question on W...
by
EventHorizon
[March 27, 2024, 10:18:38 pm]
need advice about the fol...
by
jamie
[March 27, 2024, 09:56:39 pm]
[SOLVED] Completion box s...
by
Martin_fr
[March 27, 2024, 08:44:09 pm]
Dialog ShowModal and an i...
by
d7_2_laz
[March 27, 2024, 08:25:18 pm]
Offical launch of the 1 B...
by
Gustavo 'Gus' Carreno
[March 27, 2024, 07:41:48 pm]
Problem setting length of...
by
Remy Lebeau
[March 27, 2024, 05:41:10 pm]
TDBLookupcombobox seems u...
by
Fantablup
[March 27, 2024, 05:18:04 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 2581 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