純粋なWindows GDI
を使用して(GDI +、DirectXなどを使用せず、OpenGLを使用せず、アセンブラもサードパーティのライブラリも使用しないで)キャンバスの領域を混色(指定アルファ値で色付け)したいと思います。この関数は見何をすべきかの概念について純粋なGDIを使用してキャンバス領域を色分け(指定されたアルファ値で色付け)する方法は?
procedure ColorBlend(const ACanvas: HDC; const ARect: TRect;
const ABlendColor: TColor; const ABlendValue: Integer);
var
DC: HDC;
Brush: HBRUSH;
Bitmap: HBITMAP;
BlendFunction: TBlendFunction;
begin
DC := CreateCompatibleDC(ACanvas);
Bitmap := CreateCompatibleBitmap(ACanvas, ARect.Right - ARect.Left,
ARect.Bottom - ARect.Top);
Brush := CreateSolidBrush(ColorToRGB(ABlendColor));
try
SelectObject(DC, Bitmap);
Windows.FillRect(DC, Rect(0, 0, ARect.Right - ARect.Left,
ARect.Bottom - ARect.Top), Brush);
BlendFunction.BlendOp := AC_SRC_OVER;
BlendFunction.BlendFlags := 0;
BlendFunction.AlphaFormat := 0;
BlendFunction.SourceConstantAlpha := ABlendValue;
Windows.AlphaBlend(ACanvas, ARect.Left, ARect.Top,
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top, DC, 0, 0,
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top, BlendFunction);
finally
DeleteObject(Brush);
DeleteObject(Bitmap);
DeleteDC(DC);
end;
end;
を
:私は次の関数を作成しましたし、私はこれを行うには、より効率的か、もっと簡単な方法があるかどうかを知りたいのですが:-)画像を識別(以下:
上記に示すように、フォームの上部左側にthis image
をレンダリングすることができるコード:
uses
PNGImage;
procedure TForm1.Button1Click(Sender: TObject);
var
Image: TPNGImage;
begin
Image := TPNGImage.Create;
try
Image.LoadFromFile('d:\6G3Eg.png');
ColorBlend(Image.Canvas.Handle, Image.Canvas.ClipRect, $0000FF80, 175);
Canvas.Draw(0, 0, Image);
finally
Image.Free;
end;
end;
これを行うには、純粋なGDIまたはDelphi VCLを使用するより効率的な方法がありますか?
あなたは何を既に持っていることは効率的ではないと思うのはなぜ? –
だから私は尋ねた。私はそれが効率的だと知っているが、私はより多くの(可能であれば:-)をしたい – TLama
あなたはそれから何をもっとしたいですか? –