Autor Beitrag
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Mi 02.07.03 21:50 
Ich hab mir mal das Beispiel für Scanline angesehen und das sieht so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TForm1.Button1Click(Sender: TObject);

// Dieses Beispiel zeigt das direkte Zeichnen in das BitMap
var
  x,y : Integer;
  BitMap : TBitMap;
  P : PByteArray;
begin
  BitMap := TBitMap.create;
  try
    BitMap.LoadFromFile('..\Images\Splash\256color\factory.bmp');
    for y := 0 to BitMap.height -1 do
    begin
      P := BitMap.ScanLine[y];
      for x := 0 to BitMap.width -1 do
        P[x] := y;
    end;
  Canvas.draw(0,0,BitMap);

  finally
    BitMap.free;
  end;
end;


Jedoch frage ich mich was das soll. Nachdem ich den Pfad korrigiert habe bekomme ich nur so linien von denen ich nicht weiß warum sie welche Farbe haben, geschweige denn was sie mit dem Bild zu tun haben...

Was soll das Beispiel bitte aussagen...

Da steht dran "Dieses Beispiel zeigt das direkte Zeichnen in das BitMap"... Tolll...

Ich möchte wissen wie ich per Scanline das Pixels[x,y] schneller machen kann...

So, also???

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.07.03 21:54 
Hi,

also den sinn des Beispiels versteh ich auch grad net so ganz... ;)
Versuch es mal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
procedure TForm1.Button1Click(Sender: TObject); 

// Dieses Beispiel zeigt das direkte Zeichnen in das BitMap 
var 
  x,y : Integer; 
  BitMap : TBitMap; 
  P : PByteArray; 
begin 
  BitMap := TBitMap.create; 
  try 
    BitMap.LoadFromFile('..\Images\Splash\256color\factory.bmp'); 
    for y := 0 to BitMap.height -1 do 
    begin 
      P := BitMap.ScanLine[y]; 
      for x := 0 to BitMap.width -1 do  begin
        P[x*3+0] := 128// Blau
        P[x*3+1] := 128// Grün
        P[x*3+2] := 128// Rot
      end;
    end
  Canvas.draw(0,0,BitMap); 

  finally 
    BitMap.free; 
  end
end;


Das sollte rein theoretisch eine komplett graue Fläche ergeben... ;)

Ist es so etwas klarer? :)

Au'revoir,
Aya~

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

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Mi 02.07.03 22:01 
Das gibt bei mir nur ne grüne Fläche...

Für was stehen da z.B. das x*3+0 ???

Ich würde halt gerne Wissen wie ich direkt in ein Bitmap zeichne (ohne Pixels[x,y])

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.07.03 22:15 
Also... in P ist eine waagerechte Linie deines Bitmaps gepsichert, und zwar Byte an Byte (Halt ein Pointer auf einen Speicherbereich)

mit for X... gehst du da jetzt durch diese eine Zeile des bildes.
X*3 deswegen, weil eine Farbe immer 3 Byte werte hat. Und damit du dann auf R,G,B zugreifen kannst halt noch +0, +1 und +2.

Im grunde kannst du dir die Zeile so vorstellen:
Row = R,G,B,R,G,B,R,G,B,R,G,B,R,G,B
mit X*3+0 würdest du bei X=0 auf das erste R zugreifen, mit X*3+1 auf das erste G...
mit X*3+2 würdest du bei X=3 auf den 11ten Wert zugreifen also auf das 4te G.

Au'revoir,
Aya~

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

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Mi 02.07.03 22:19 
Hmm, sagen wir mal ich möchte nur rot mit blau vertauschen. DAnn mach ich ja z.B. so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
      for x := 0 to BitMap.width -1 do  begin
        r := P[x*3+2];
        g := P[x*3+1];
        b := P[x*3+0];

        P[x*3+0] := r;// Blau
        P[x*3+1] := g;// Grün
        P[x*3+2] := b;// Rot
      end;



Aber das geht nicht. Warum?

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.07.03 22:26 
Hi,

also bei mir funktioniert das mit den FarbenTauschen... evtl solltest du mal ein sehr buntes Bild nehmen ;) (Bzw eins wo Rot drin is *g*)

Au'revoir,
Aya~

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


D6 Prof
BeitragVerfasst: Mi 02.07.03 22:27 
Hmm, liegt es vielleicht daran, dass Du eine 256-Farben-Bitmap geladen hast? Dann belegt IMHO jeder Pixel ein Byte, und zwar ein Byte für den Index in der Palette. Versuch's mal mit 'ner 24Bit-Bitmap, dann sollte es klappen.

_________________
In the beginning, the universe was created. This has made a lot of people very angry, and is generally considered to have been a bad move.
Tweafis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Mi 02.07.03 22:29 
Bei mir ist das Bild dann nur so verzerrt :shock:

Liegt wahrscheinlich an der Delphi Version, oder)

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.07.03 23:44 
Hi,

mach mal das:
ausblenden Delphi-Quelltext
1:
2:
  BitMap.LoadFromFile(...);
  BitMap.PixelFormat:=pf24Bit;


Dann sollte es gehen. (Damit halt jedes Pixel 3 Byte belegt)

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!