|
#1
|
|||
|
|||
Картинка
Как можно сделать выведенное на форму изображение полупрозрачным?
|
#2
|
|||
|
|||
На мой взгляд, это лучше делать с помощью графического интерфейса 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; Последний раз редактировалось Nyctos Kasignete, 07.04.2009 в 10:30. |
#3
|
|||
|
|||
Спасибо.
|