How to get Integer from Pointer
Hello,
I have a TBitmap or TPaintBox and I scanline to get pointer to first line...
Code:
Then I have
ps0 := DWORD(bm1.scanline[0]);
Code:
MyColor:= how to make the cast to get the color in integer?
type TRGBColor = Integer;
var pFirstByte:DWord; MyColor: TRGBColor; This is just for comparison of colors, the order of bytes is not important here. |
AW: How to get Integer from Pointer
1. I'm not sure why you're posting in English here, when there's an English forum over at en.delphipraxis.net but welcome here anyway.
2. Why don't you declare a pointer to that TRGBType and let that one point to the scanline property? By incremeinting that pointer you can scan 4 bytes forwards then. Something like this one:
Delphi-Quellcode:
type
TRGBColor = Integer; var pFirstByte:^TRGBColor; MyColor: TRGBColor; begin pFirstByte := DWORD(bm1.scanline[0]); MyColor := pFirstByte^; inc(pFirstByte); // point to the next color(s) MyColor := pFirstByte^; |
AW: How to get Integer from Pointer
Because I have type like this:
Code:
pArr is container of sampled pixels. By sampled I mean, that I have picked up colors from image and store them there.
type Arr =
// Array[1..9] represents the sampled pixels around and including current position Array[1..256] of Array[1..256] of Array[1..9] of TRGBColor; type PArray = ^Arr; ... new(pArr); |
AW: How to get Integer from Pointer
I have found solution.
Code:
:-D
new(pArr);
p := pFirstByte; pArr^[1][1][1]:=PINT(p)^; // Test of the first pixel color I have found help in code of David Dirkse. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:02 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz