![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Уважаемые. Нужна помощь в переводе кода с си на Delphi. На входе будут два экземпляра TBitmap, а лучше HBITMAP.
Код:
[DllImport("msvcrt.dll")]
private static extern int memcmp(IntPtr b1, IntPtr b2, long count);
public static bool CompareMemCmp(Bitmap b1, Bitmap b2)
{
if ((b1 == null) != (b2 == null)) return false;
if (b1.Size != b2.Size) return false;
var bd1 = b1.LockBits(new Rectangle(new Point(0, 0), b1.Size), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
var bd2 = b2.LockBits(new Rectangle(new Point(0, 0), b2.Size), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
try
{
IntPtr bd1scan0 = bd1.Scan0;
IntPtr bd2scan0 = bd2.Scan0;
int stride = bd1.Stride;
int len = stride * b1.Height;
return memcmp(bd1scan0, bd2scan0, len) == 0;
}
finally
{
b1.UnlockBits(bd1);
b2.UnlockBits(bd2);
}Последний раз редактировалось xteam777, 25.06.2018 в 09:58. |
|
#2
|
|||
|
|||
|
|
|
#3
|
||||
|
||||
|
Цитата:
Код:
function IsSameBitmapUsingScanLine(B1, B2: TBitmap): boolean;
var
i : Integer;
ScanBytes : Integer;
begin
Result:= (B1<>nil) and (B2<>nil);
if not Result then exit;
Result:=(b1.Width=b2.Width) and (b1.Height=b2.Height) and (b1.PixelFormat=b2.PixelFormat) ;
if not Result then exit;
ScanBytes := Abs(Integer(B1.Scanline[1]) - Integer(B1.Scanline[0]));
for i:=0 to B1.Height-1 do
Begin
Result:=CompareMem(B1.ScanLine[i],B2.ScanLine[i],ScanBytes);
if not Result then exit;
End;
end; |