AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

How to get Integer from Pointer

Ein Thema von neumimnemecky · begonnen am 23. Nov 2022 · letzter Beitrag vom 23. Nov 2022
Antwort Antwort
neumimnemecky

Registriert seit: 21. Dez 2018
45 Beiträge
 
#1

How to get Integer from Pointer

  Alt 23. Nov 2022, 18:35
Hello,
I have a TBitmap or TPaintBox and I scanline to get pointer to first line...

Code:
ps0 := DWORD(bm1.scanline[0]);
Then I have
Code:
type TRGBColor = Integer;
var pFirstByte:DWord;
MyColor: TRGBColor;
MyColor:= how to make the cast to get the color in integer?

This is just for comparison of colors, the order of bytes is not important here.

Geändert von neumimnemecky (23. Nov 2022 um 18:37 Uhr)
  Mit Zitat antworten Zitat
TurboMagic

Registriert seit: 28. Feb 2016
Ort: Nordost Baden-Württemberg
2.812 Beiträge
 
Delphi 12 Athens
 
#2

AW: How to get Integer from Pointer

  Alt 23. Nov 2022, 18:50
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^;
  Mit Zitat antworten Zitat
neumimnemecky

Registriert seit: 21. Dez 2018
45 Beiträge
 
#3

AW: How to get Integer from Pointer

  Alt 23. Nov 2022, 19:14
Because I have type like this:

Code:
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);
pArr is container of sampled pixels. By sampled I mean, that I have picked up colors from image and store them there.
  Mit Zitat antworten Zitat
neumimnemecky

Registriert seit: 21. Dez 2018
45 Beiträge
 
#4

AW: How to get Integer from Pointer

  Alt 23. Nov 2022, 20:57
I have found solution.

Code:
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.
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:33 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