Witam,
mam problem z wyświetleniem obrazka w formacie PNG na pulpicie,
obrazek wyświetla się na wpół przezroczysty i nie mam pojęcia jak to naprawić,
po oknie rysuje w taki sposób:
procedure DrawLayered(Window:THandle);
var
s : string;
tf : textfile;
i : integer;
var
blend:BLENDFUNCTION;
P:TPoint;
Ss:TSize;
X,Y:integer;
RGBAPixel:PRGBQuad;
RGBPixel:PRGBTriple;
APixel:PByte;
begin
RGBA := CreateBitmap(250, 250, pf32bit);
Rgbb := CreateBitmap(250, 250, pf24bit);
A := CreateBitmap(250, 250, pf8bit);
try
png := tpngobject.Create;
png.LoadFromFile('C:\1.png');
png.CreateAlpha;
a.Canvas.Brush.Color := clblack;
a.Canvas.Rectangle(0,0,a.Height,a.width);
rgbb.Canvas.Draw(0,0,png);
a.Canvas.Draw(0,0,png);
for Y := RGBA.Height-1 downto 0 do
begin
RGBAPixel:=RGBA.ScanLine[y];
RGBPixel:=RGBb.ScanLine[y];
APixel:=A.ScanLine[y];
for X := 0 to RGBA.Width-1 do
begin
RGBAPixel.rgbReserved := APixel^;
RGBAPixel.rgbRed := MulDiv(RGBPixel.rgbtRed, APixel^, 255);
RGBAPixel.rgbGreen := MulDiv(RGBPixel.rgbtGreen, APixel^, 255);
RGBAPixel.rgbBlue := MulDiv(RGBPixel.rgbtBlue, APixel^, 255);
inc(RGBAPixel);
inc(RGBPixel);
inc(APixel);
end;
end;
P.X := 0;
P.Y := 0;
Ss.cx := RGBA.Width;
Ss.cy := RGBA.Height;
blend.BlendOp := AC_SRC_OVER;
blend.BlendFlags := 0;
blend.AlphaFormat := AC_SRC_ALPHA;
blend.SourceConstantAlpha := 255;
UpdateLayeredWindow(Window, GetDC(0), nil, @Ss, rgba.Canvas.handle, @P, 0, @blend, ULW_ALPHA);
finally
RGBA.Free;
RGBb.Free;
A.Free;
end;
end;
tworzenie okna:
Window:=CreateWindowEx(WS_EX_TOOLWINDOW or WS_EX_LAYERED, 'Aa',
'Aa',WS_VISIBLE, 500, 20, 250, 250, GetDesktopListViewHandle, 0, hInstance, nil);
SetWindowPos(Window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE);
SetParent(Window, GetDesktopListViewHandle);
DrawLayered(Window);
z rysowaniem po canvasie nie ma problemu, dopiero przy obrazie pojawia się problem.
Pomocy. 2 dzień się nad tym głowię.