Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
(Moderator:
Ask
) »
Does GetPixel work with TBGRABitmap?
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
XLibre, finally and fortu...
by
Fred vS
[
Today
at 04:34:20 pm]
[New Component] ExtTabCtr...
by
ovidio
[
Today
at 04:22:52 pm]
made hooking newinstance ...
by
runewalsh
[
Today
at 04:00:13 pm]
Sizes and SizeInt
by
LemonParty
[
Today
at 03:05:53 pm]
How can 'Canvas does not ...
by
J-G
[
Today
at 03:05:01 pm]
AArch64. Fast method to c...
by
Thaddy
[
Today
at 01:58:45 pm]
I found an actual use for...
by
Thaddy
[
Today
at 01:07:16 pm]
Strange Behaviour at Runt...
by
andrew Bubble
[
Today
at 12:41:49 pm]
water filling simulation
by
Dzandaa
[
Today
at 12:35:32 pm]
Can /my/ AI help me with ...
by
microxa
[
Today
at 12:12:06 pm]
Knigo
by
CM630
[
Today
at 12:05:31 pm]
P.I.S.S. a PlugIn-framewo...
by
cdbc
[
Today
at 11:27:35 am]
[solved] rotate image pro...
by
speter
[
Today
at 10:03:42 am]
Lazarus Main and Gnome/Wa...
by
zeljko
[
Today
at 09:06:57 am]
TstringGrid read cell col...
by
Josh
[June 08, 2026, 11:05:23 pm]
Pascal for AI Agent CLI T...
by
schuler
[June 08, 2026, 10:35:41 pm]
is there a Base 26 / Radi...
by
Josh
[June 08, 2026, 08:54:36 pm]
FPC Unleashed (inline var...
by
Fibonacci
[June 08, 2026, 08:49:31 pm]
Notetask 1.1.4 - Free cro...
by
AlexanderT
[June 08, 2026, 04:55:38 pm]
Pixie: A lightweight HTML...
by
Tomxe
[June 08, 2026, 01:48:30 pm]
EasyLazFreeType Bug?
by
Tommi
[June 08, 2026, 10:57:47 am]
embed .jpg file into .pp ...
by
Thaddy
[June 08, 2026, 09:51:38 am]
Call SetLength from assem...
by
Thaddy
[June 08, 2026, 09:00:36 am]
TPlaysound problem Ubuntu...
by
jamie
[June 08, 2026, 12:57:32 am]
Portable verion of FPC an...
by
Martin_fr
[June 08, 2026, 12:26:26 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Does GetPixel work with TBGRABitmap? (Read 1599 times)
user5
Sr. Member
Posts: 419
Does GetPixel work with TBGRABitmap?
«
on:
December 17, 2019, 10:59:24 am »
I can't get GetPixel(x,y) to work with TBGRABitmap. The code below keeps coming up with clNone. Can someone show me what I'm doing wrong or show me a simple example of how to use GetPixel with TBGRABitmap? Thanks.
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Button12Click
(
Sender
:
TObject
)
;
var
mybitmap
:
TBitmap
;
bgra
:
TBGRABitmap
;
tempcolor
:
TColor
;
tempstr
:
string
;
begin
mybitmap
:
=
TBitmap
.
create
;
mybitmap
.
width
:
=
image1
.
width
;
mybitmap
.
height
:
=
image1
.
height
;
mybitmap
.
assign
(
image1
.
picture
.
bitmap
)
;
application
.
processmessages
;
bgra
:
=
TBGRABitmap
.
create
(
mybitmap
.
width
,
mybitmap
.
height
)
;
bgra
.
assign
(
mybitmap
)
;
tempcolor
:
=
bgra
.
GetPixel
(
30
,
30
)
;
tempstr
:
=
ColorToString
(
tempcolor
)
;
edit1
.
text
:
=
tempstr
;
bgra
.
free
;
mybitmap
.
free
;
end
;
Logged
user5
Sr. Member
Posts: 419
Re: Does GetPixel work with TBGRABitmap?
«
Reply #1 on:
December 17, 2019, 01:00:02 pm »
I did some research and testing and found something that works. If anyone is interested the code below works with GetPixel and BGRABitmap. Thanks anyway.
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Button12Click
(
Sender
:
TObject
)
;
var
mybitmap
:
TBitmap
;
bgra
:
TBGRABitmap
;
tempcolor
:
TColor
;
tempstr
:
string
;
c
:
TBGRAPixel
;
begin
mybitmap
:
=
TBitmap
.
create
;
mybitmap
.
width
:
=
image1
.
width
;
mybitmap
.
height
:
=
image1
.
height
;
mybitmap
.
assign
(
image1
.
picture
.
bitmap
)
;
application
.
processmessages
;
bgra
:
=
TBGRABitmap
.
create
(
mybitmap
.
width
,
mybitmap
.
height
)
;
bgra
.
assign
(
mybitmap
)
;
c
:
=
bgra
.
GetPixel
(
30
,
30
)
;
tempcolor
:
=
BGRAToColor
(
c
)
;
tempstr
:
=
ColorToString
(
tempcolor
)
;
edit1
.
text
:
=
tempstr
;
bgra
.
free
;
mybitmap
.
free
;
end
;
Logged
circular
Hero Member
Posts: 4471
Re: Does GetPixel work with TBGRABitmap?
«
Reply #2 on:
December 19, 2019, 04:53:40 pm »
You can try something like
bgra.GetPixel(30,30).ToColor
Logged
Conscience is the debugger of the mind
winni
Hero Member
Posts: 3197
Re: Does GetPixel work with TBGRABitmap?
«
Reply #3 on:
December 19, 2019, 05:29:10 pm »
@user5
You can simplify your code. Your lines 15 & 16 could be pulled to one line.
From
Code: Pascal
[Select]
[+]
[-]
bgra
:
=
TBGRABitmap
.
create
(
mybitmap
.
width
,
mybitmap
.
height
)
;
bgra
.
assign
(
mybitmap
)
;
To
Code: Pascal
[Select]
[+]
[-]
bgra
:
=
TBGRABitmap
.
create
(
mybitmap
)
;
It creates a TBGRABitmap with height and width of myBitmap and then it make a copy.
Winni
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Graphics and Multimedia
»
Graphics
(Moderator:
Ask
) »
Does GetPixel work with TBGRABitmap?
TinyPortal
© 2005-2018