|
델파이 소스를 C빌더로 변환해서 쓰려고 하는데 좀 막혀버리네요
델파이 소스와 변환 소스롤 올려드리니 에러나는 부분좀 해결해 주세요.
*델파이소스
function TIEJpegAcquireStream.Write(const Buffer; Count: Longint): Longint;
var
buf:pbytearray;
i:integer;
begin
result:=Count;
buf:=pbytearray(@Buffer);
case fStart of
false:
// look for begin of jpeg (FFD8)
for i:=0 to Count-2 do
if (buf[i]=$FF) and (buf[i+1]=$D8) then
begin
fData.Write( buf[i], Count-i);
fStart:=true;
exit;
end;
true:
begin
// look for end of jpeg (FFD9)
for i:=0 to Count-2 do
if (buf[i]=$FF) and (buf[i+1]=$D9) then
begin
fData.Write( buf[0], i);
fStart:=false;
// acquire bitmap
fData.Position:=0;
Form1.ImageEnView1.IO.LoadFromStreamJpeg(fData);
Application.ProcessMessages;
fData.Clear;
exit;
end;
// not found, write all
fData.Write( buf[0], Count );
end;
end;
end;
*변환소스
int __fastcall TIEJpegAcquireStream::Write(const void *Buffer, int Count)
{
PByteArray buf;
int i;
//long nCount = Count;
buf = PByteArray(Buffer);
switch (fStart) {
// look for begin of jpeg (FFD8)
case false:
for (i = 0; i < Count-2; i++) {
if (buf[i] == "0xFF" && buf[i+1] == "0xD8") { <--- 이부분과
fData->Write(buf[i], Count-i);
fStart = true;
break;
}
}
// look for end of jpeg (FFD9)
case true:
for (i = 0; i < Count-2; i++) {
if (buf[i] == "0xFF" && buf[i+1] == "0xD9") { <--- 이부분에서 제대로 IF문을 수행하지 못하네요 ㅠㅠ
fData->Write(buf[0], i);
fStart = false;
// acquire bitmap
fData->Position = 0;
Form1->ImageEnView1->IO->LoadFromStreamJpeg(fData);
Application->ProcessMessages();
fData->Clear();
break;
}
// not found, write all
fData->Write(buf[0], Count);
}
}
return Count;
}
|