
07.04.2009, 10:17
|
Активный
|
|
Регистрация: 29.03.2009
Сообщения: 300
Репутация: 94
|
|
На мой взгляд, это лучше делать с помощью графического интерфейса GDI+. Он изначально ориентировался на поддержку прозрачности.
Картинку сделать полупрозрачной можно отрисовывая ее в PaintBox'е по событию OnPaint:
Код:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, ToolWin, GDIPAPI, GDIPOBJ, StdCtrls, jpeg;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
procedure PaintBox1Paint(Sender: TObject);
private
{ Private declarations }
graphicsGDIPlus : TGPGraphics;
public
{ Public declarations }
end;
.....
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
bitmap: TGPBitmap;
ImageWidth, Imageheight: UINT;
Row, Column: Integer;
color, colorTemp: TGPColor;
begin
graphicsGDIPlus := TGPGraphics.Create(PaintBox1.Canvas.Handle);
Bitmap := TGPBitmap.Create('Ваше_изображение.jpg');
ImageWidth := bitmap.GetWidth;
ImageHeight := bitmap.GetHeight;
for Row := 0 to ImageHeight - 1 do
for Column := 0 to ImageWidth - 1 do
begin
bitmap.GetPixel(Column, Row, color);
// Ниже 100 — это степень непрозрачности (вообще — от 0 до 255)
colorTemp := MakeColor(100, GetRed(color), GetGreen(color), GetBlue(color));
bitmap.SetPixel(Column, Row, colorTemp);
end;
graphicsGDIPlus.DrawImage(bitmap, 0, 0, ImageWidth, ImageHeight);
Bitmap.Free;
graphicsGDIPlus.Free;
end;
|