Autor Beitrag
Delphianer23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 156



BeitragVerfasst: Fr 21.02.03 20:21 
Hab schon gesucht, aber die Themen haben mir nicht
weitergeholfen.
Es soll

Ich berechne jeden Pixel einzel.
Wie soll ich ihn dann ausgeben mit scanline?


So (sehr sehr) vereinfacht sieht mein code mit pixel[] aus


y:=-1;
repeat
inc(y);

x:=-1;
repeat
inc(x);

//Rechnung für Farbe //rechnefarbe(x,y)

Bitmap1.canvas.pixel[x,y]:=RGB(//Berechnete Werte//)

until x = 200;

until y = 200;



Wie mach ich den code mit scanline?
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Fr 21.02.03 20:35 
Hi,

das is dahier hab ich zum testen benutzt was schneller ist... (siehe anderes Topic im Freeware Bereich):

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
  x, y: Integer;
  bit: TBitmap;
  P: PByteArray;
begin
  Bit:=TBitmap.Create;
  Bit.PixelFormat:=pf24Bit;
  Bit.Width:=Image.Width;
  Bit.Height:=Image.Height;
  for y:=0 to Bit.Height-1 do begin
    P:=Bit.ScanLine[y];
    for x:=0 to Bit.Width-1 do begin
      P^[x*3]:=255; // Blau
      P^[x*3+1]:=0;    // Rot
      P^[x*3+2]:=0;    // Grün
    end;
  end;
  Image.Canvas.Draw(0,0,Bit);
  Bit.Free;
end;


in P wird die Scanline für jede Horrizontale Linie des Bitmaps gespeichert, in der 2ten For-Schleife wird dann jedem einzelnen Wert in diesem Array ein wert zugewiesen.
x*3 daher, weil es ja 3 Werte sind, R, G und B... :)

Hoffe das hat dir geholfen.

Au'revoir,
Aya

_________________
Aya
I aim for my endless dreams and I know they will come true!
Delphianer23 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 156



BeitragVerfasst: Fr 21.02.03 21:15 
Danke habs verstanden, nur sieht das Bild von den Farben her
ganz anders aus.


Ich hab auch drauf geachtet dass wirklich rot bei rot ist usw.

Aber es sieht trotzdem ganz anders aus.

Was könnte es noch sein?
Sie die irgendwie noch anders defieniert?
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Fr 21.02.03 21:28 
Mhh.. ne, so wie in meinem beispiel stimmt es schon.. du hast wahrscheinlich irgendwie die farben verdreht.. *g*

Denk dran, $00FF0000 in Delphi ist nicht Rot, sondern Blau!

_________________
Aya
I aim for my endless dreams and I know they will come true!
OregonGhost
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 215



BeitragVerfasst: Sa 22.02.03 12:54 
Aya hat folgendes geschrieben:

P^[x*3]:=255; // Blau
P^[x*3+1]:=0; // Rot
P^[x*3+2]:=0; // Grün

Bist du sicher? Wenn ich mich recht erinnere, ist die Reihenfolge in Win32-DIBs BGR und nicht BRG.
Aber das nur mal so als Ergänzung.

_________________
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Sa 22.02.03 16:37 
arg ups... klar.. BGR... sorry :oops:
War ich wohl mit gedanken ein wenig durcheinander als ich das geschrieben habe..

_________________
Aya
I aim for my endless dreams and I know they will come true!
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Sa 22.02.03 17:58 
Hi, ihr scanner.

Was auch noch wichtig wär, ist 'PixelFormat' damit man überhaupt auf das aktuelle Farb-format reagieren kann. Bei 32 bit liegen die daten in BGRX order und bei 24 bit in BGR, wie ihr schon sagtet :)

bis denn. mx