was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

34 Visitors Online


 
...ein Bitmap invertieren?
Autor: Katja Hoffmann
Homepage: http://www.katjahoffmann.gmxhome.de
[ Tip ausdrucken ]  

Tip Bewertung (3):  
     


function InvertBmp1(SourceBmp: TBitmap): TBitMap;
var
  
i, j: Longint;
  tmp: TBitMap;
  red, green, blue: Byte;
  PixelColor: Longint;
begin
  
tmp := TBitmap.Create;
  tmp.Width  := SourceBmp.Width;
  tmp.Height := SourceBmp.Height;
  for i := 0 to SourceBmp.Width - 1 do
  begin
    for 
j := 0 to SourceBmp.Height - 1 do
    begin
      
PixelColor := ColorToRGB(SourceBmp.Canvas.Pixels[i, j]);
      red := PixelColor;
      green := PixelColor shr 8;
      blue := PixelColor shr 16;
      red  := 255 - red;
      green := 255 - green;
      blue := 255 - blue;
      tmp.Canvas.pixels[i, j] := (red shl 8 + green) shl 8 + blue;
    end;
  end;
  Result := tmp;
end;

function InvertBmp2(ABitmap : TBitmap) : TBitmap;
var
  
l_bmp : TBitmap;
begin
  
l_bmp := TBitmap.Create;
  l_bmp.Width := ABitmap.Width;
  l_bmp.Height := ABitmap.Height;
  l_bmp.PixelFormat := ABitmap.PixelFormat;
  BitBlt( l_bmp.Canvas.Handle, 0, 0, l_bmp.Width, l_bmp.Height,
    ABitmap.Canvas.Handle, 0, 0, SRCINVERT );
  result := l_bmp;
end;

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners