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
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
Demo Scene Picture sinwav...
by
Gigatron
[
Today
at 12:48:52 am]
open dialog - default dir...
by
KodeZwerg
[
Today
at 12:34:53 am]
Can function be used for ...
by
jamie
[
Today
at 12:26:42 am]
DbGrid, grid column check...
by
KodeZwerg
[
Today
at 12:08:29 am]
Colore celle StringGrid
by
JuanBell
[April 24, 2024, 10:37:56 pm]
Likely bug
by
440bx
[April 24, 2024, 10:12:59 pm]
Any upgrades to fpWeb pag...
by
verasan
[April 24, 2024, 10:11:46 pm]
Web Applications with Pas...
by
Handoko
[April 24, 2024, 08:56:29 pm]
AI, NLP and CAI: Text Gen...
by
indydev
[April 24, 2024, 08:54:00 pm]
Offical launch of the 1 B...
by
Gustavo 'Gus' Carreno
[April 24, 2024, 08:48:22 pm]
Multidimensional arrays a...
by
KodeZwerg
[April 24, 2024, 08:34:38 pm]
Ho Ho Ho IntraWeb in Laza...
by
Thaddy
[April 24, 2024, 08:31:29 pm]
[SOLVED] System.Now gives...
by
alpine
[April 24, 2024, 08:29:19 pm]
Installing and using Vamp...
by
Odacir
[April 24, 2024, 07:58:22 pm]
Demo Scene Bitmap Font Sc...
by
KodeZwerg
[April 24, 2024, 07:21:14 pm]
what's difference between...
by
ASerge
[April 24, 2024, 07:09:52 pm]
splitting an image
by
KodeZwerg
[April 24, 2024, 07:07:21 pm]
Debugger error
by
bobonwhidbey
[April 24, 2024, 07:03:07 pm]
How to: create DLL file f...
by
paule32
[April 24, 2024, 07:02:31 pm]
Your best UI design - con...
by
circular
[April 24, 2024, 06:48:12 pm]
Converting a string/index...
by
1HuntnMan
[April 24, 2024, 06:35:19 pm]
Drawing grid lines on a t...
by
KodeZwerg
[April 24, 2024, 05:42:19 pm]
Compile/Convert Delphi pr...
by
Martin_fr
[April 24, 2024, 05:29:03 pm]
Lazarus features in a non...
by
Lutz Mändle
[April 24, 2024, 05:26:34 pm]
Lazarus for Windows on aa...
by
msintle
[April 24, 2024, 05:03:57 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Does GetPixel work with TBGRABitmap? (Read 1245 times)
user5
Sr. Member
Posts: 357
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: 357
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: 4224
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