Autor Beitrag
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Di 19.08.03 12:20 
Hallo!

Ich möchte ein Bild bleichen also z.B. aus Schwarz wird grau oder so, kann mir jemand sagen wie das geht?

Stefan

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
umpani
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 389



BeitragVerfasst: Di 19.08.03 16:18 
Also. Dazu musst du die von scanline übergebenen drei farwerte gleichmäßig erhöhen.

Alles klar? Wenn nicht, schau dir mal dieses Bitmap-Tutorial an.

www.tutorials.delphi...bitmap/file005.shtml


Gruß Umpani

_________________
Lernen, ohne zu denken, ist eitel; denken, ohne zu lernen, ist gefährlich. Konfuzius
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Do 21.08.03 14:34 
Also erstmal Danke!

Ich hab mit Hilfe des Tut folgendes zusammengeschustert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.Button1Click(Sender: TObject);

type
  PixArray = Array [1..3of Byte;
var
  p: ^PixArray;
  h,w,i: Integer;
begin
  For h:=0 to Image1.Picture.Bitmap.Height-1 do
  begin
    p:= Image1.Picture.Bitmap.ScanLine[h];
    For w:=0 to Image1.Picture.Bitmap.Width-1 do
    begin
      for i:=1 to 3 do inc(p^[i],50);
    end;
  end;
end;


Des funzt aber net :( entweder, das Bild ist ganz weg, oder es passiert garnix

Stefan

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Mr_T
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP, Fedora Core RC 1

BeitragVerfasst: Do 21.08.03 15:42 
Hmm, also ich würde es so machen:

(tempint ist vom typ integer und bitmap ist das tbitmap, welches deine Bitmap enthält... v ist ebenfalls ein integer und beinhält die veränderung... ich denke die variablen x,y, r,g und b sind klar ;-) .... es handelt sich im übrigen um nicht getesteten speudocode ;-) )

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
for x := 0 to bitmap.width do
begin
 for y := 0 to bitmap.height do
 begin
  tempint := bitmap.canvas.pixels[x,y];
  r := TempInt and $FF;
  g := (TempInt shr 8and $FF;
  b := (TempInt shr 16and $FF;
  r := r+v;
  g := g+v;
  b := b+v;
  bitmap.canvas.pixels[x,y] := rgb(r,g,b);
 end;
end;

_________________
Es gibt 10 Arten Binäre Zahlen zu interpretieren: 0 und 1
Wer nicht kämpft, hat schon verloren!
Eggi
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 33

Win 2000, Win XP
D7 Prof
BeitragVerfasst: Do 21.08.03 16:02 
Hallo

@StefanH

Wenn ich nichts übersehen habe, müsste dein Algorithmus so funktionieren. Dein Problem ist es wohl das dein Ausgangsbild ziemlich hell ist, so das nach der Addition von 50 auf jeden Farbwert nur noch weiße Pixel herrauskommen. Ich denke mal so wird es aussehen wenn dein Bild komplett weg ist. Wenn sich an einem Bild nichts änders nutzt du wohl einen zu kleinen Parameter. Geringe Änderungen sieht man nicht so leicht.

@Mr_T

Versuch solche Operationen bloß nicht über canvas.pixels[x,y] auszuführen. Außer du machst gerne Kaffeepausen *grins*, das ist nämlich total langsam.

mfg Eggi
kasi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37

Win XP
D5 Ent
BeitragVerfasst: Do 21.08.03 18:37 
@StefanH
Du durchläuft den w-Wert nicht p steht immer auf dem linken Pixel. So funktioniert es:
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);
const
  MAXBITMAPCOLS = 2048;
  
type
  TRGBTripleArray = array[0..MAXBITMAPCOLS] of TRGBTriple;
  PRGBTripleArray = ^TRGBTripleArray;
var
  p: PRGBTripleArray;
  h,w: Integer;
begin 
  For h:=0 to Image1.Picture.Bitmap.Height-1 do 
  begin 
    p:= Image1.Picture.Bitmap.ScanLine[h]; 
    For w:=0 to Image1.Picture.Bitmap.Width-1 do 
    begin
      p[w].rgbtBlue := min(255,p[w].rgbtBlue+10);
      p[w].rgbtGreen := min(255,p[w].rgbtGreen+10);
      p[w].rgbtRed := min(255,p[w].rgbtRed+10);
    end;
  end;
Image1.Repaint;
end;

TRGBTriple ist in windows.pas und min in math.pas definiert

KASI

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Do 21.08.03 19:45 
@Eggi: ICh hab immer 50 genommen. und die Form ist grau und das Bitmap auch...


@Kasi: Deins geht aber:
Zitat:
Du durchläuft den w-Wert nicht p steht immer auf dem linken Pixel.

Zitat:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
For w:=0 to Image1.Picture.Bitmap.Width-1 do 
    begin 
      for i:=1 to 3 do inc(p^[i],50); 
    end;


Was ist das?

Stefan

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Do 21.08.03 19:50 
Hm, eine umständliche Variante von inc(p^[i],150); ?
kasi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37

Win XP
D5 Ent
BeitragVerfasst: Do 21.08.03 20:11 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  For h:=0 to Image1.Picture.Bitmap.Height-1 do 
  begin 
    p:= Image1.Picture.Bitmap.ScanLine[h]; 
    For w:=0 to Image1.Picture.Bitmap.Width-1 do 
    begin 
      for i:=1 to 3 do inc(p^[i],50); 
    end
  end;


Du setzt den Zeiger auf das erste Pixel der h-ten Zeile dann erhöhst du Bitmap.Width mal die RGB-Werte um 50. Der Zeiger bleibt an der gleichen Stelle.

KASI

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.