谁能将下面的C语句翻译成Delphi(pascal) ( 积分: 100 )

  • 主题发起人 wang_cai1
  • 开始时间
W

wang_cai1

Unregistered / Unconfirmed
GUEST, unregistred user!
HDC hdcTemp=GetDC()->m_hDC;
m_hdcMemory=CreateCompatibleDC(hdcTemp);
HBITMAP hBitMap=CreateCompatibleBitmap(hdcTemp,m_BakWidth,m_BakHeight);
SelectObject(m_hdcMemory,hBitMap);
if(Transparent<0||Transparent>100) Transparent=100;
m_Blend.
SourceConstantAlpha=int(Transparent*2.55);//1~255
HDC hdcScreen=::GetDC (m_hWnd);
RECT rct;
GetWindowRect(&amp;rct);
POINT ptWinPos={rct.left,rct.top};
Graphics graph(m_hdcMemory);
 
代码都好象不全啊!
 
DELPHI里面基本上把C++的数据类型都拿过来了,SDK基本上也都引用过来了。你觉得会有问题吗?
 
这个是什么东西的demo?视频编解码器??
是截图功能吗?
要是错了就当我没说:)
 
这是代码的一部分,是使用GDI+进行图像叠加的
 
主要是Graphics graph(m_hdcMemory);这句怎么翻译
 
var
......
graph:TGraphics;
begin
......
graph:=TGraphics.Create(m_hdcMemory);
......
end;

猜的:p
 
creation-zy:有点接近,但graph:=TGraphics.Create(m_hdcMemory);中TGraphic.Create是不带参数的
 
var
......
graph:TGraphics;
begin
......
graph:=TGraphics(m_hdcMemory);
......
end;

猜的:p
 
贴一段相似代码
function GetImageMask(Image: TBitmap;
ColorValid: boolean;
AColor: TColor): TBitmap;
var
TransparentColor: TColor;
cColor: TColorRef;
bmAndObject, bmObjectOld: HBitmap;
hdcObject, hdcTemp, DC: HDC;
ptSize: TPoint;
Pal: HPalette;
begin
DC := GetDC(0);
if ColorValid then
TransparentColor := AColor {color has already been selected}
else
{set the transparent color to be the lower left pixel of the bitmap}
TransparentColor := Image.Canvas.Pixels[0, Image.Height - 1];
TransparentColor := TransparentColor or $02000000;
hdcTemp := CreateCompatibleDC(DC);
SelectObject(hdcTemp, Image.Handle);
{ select the bitmap }
{ convert bitmap dimensions from device to logical points}
ptSize.x := Image.Width;
ptSize.y := Image.Height;
DPtoLP(hdcTemp, ptSize, 1);
{ convert from device logical points }
{ create some DCs to hold temporary data}
hdcObject := CreateCompatibleDC(DC);
{ create a bitmap for each DC}
{ monochrome DC}
bmAndObject := CreateBitmap(ptSize.x, ptSize.y, 1, 1, nil);
{ each DC must select a bitmap object to store pixel data}
bmObjectOld := SelectObject(hdcObject, bmAndObject);
{ set proper mapping mode}
SetMapMode(hdcTemp, GetMapMode(DC));
{ set the background color of the source DC to the color.
contained in the parts of the bitmap that should be transparent}
Pal := Image.Palette;
SelectPalette(hdcTemp, Pal, False);
RealizePalette(hdcTemp);
cColor := SetBkColor(hdcTemp, TransparentColor);
{ create the object mask for the bitmap by performing a BitBlt()
from the source bitmap to a monochrome bitmap}
BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY);
{ set the background color of the source DC back to the original color}
SetBkColor(hdcTemp, cColor);
{Save the Object bitmap}
try
Result := TBitmap.Create;
try
Result.Handle := bmAndObject;
except
Result.Free;
raise;
end;
except
Result := nil;
end;

{ delete the memory bitmaps}
SelectObject(hdcObject, bmObjectOld);
{ delete the memory DCs}
DeleteDC(hdcObject);
DeleteDC(hdcTemp);
ReleaseDC(0, DC);
end;
 
var
hdcTemp,m_hdcMemory,hdcScreen: hdc;
hBitMap:thandle;
rct:trect;
ptWinPos:tpoints;
begin
hdcTemp:=GetDC(application.handle);
m_hdcMemory:=CreateCompatibleDC(hdcTemp);
hBitMap:=CreateCompatibleBitmap(hdcTemp,m_BakWidth,m_BakHeight);
SelectObject(m_hdcMemory,hBitMap);
if (Transparent<0) Or (Transparent>100) then
Transparent:=100;
m_Blend.
SourceConstantAlpha=int(Transparent*2.55);
hdcScreen:=GetDC (m_hWnd);
GetWindowRect(rct);
其他的因为代码不全,没有见到你的定义!
 
谢谢各位
 
顶部