PDA

View Full Version : Save AVI with Delphi7



brüll
August 20, 2006, 12:24:35
How can i save avi with delphi and get the codec params? I see the Main problem int the For Each Codec in AVICompressors structure in the given VB help.

brüll
August 21, 2006, 13:56:31
I use following prodedure for imagigng processing, how can i Save thi image buffers to an avi file.

procedure TForm1.ICImagingControl1ImageAvailable(Sender: TObject;
BufferIndex: Integer);
var
x,y,sx,sy : integer;
v : byte;

pData : PChar;
pPixel : PChar;
begin
CurrentBuffer:= ICImagingControl1.ImageActiveBuffer;
CurrentBuffer.Lock();

pData := PChar(CurrentBuffer.ImageDataPtr);

sx := ICImagingControl1.ImageWidth;
sy := ICImagingControl1.ImageHeight;

For x:= 0 to sx - 1 do
For y:= 0 To sy - 1 do
begin
{ read fast from the IC buffer }
pPixel := pData + (x + y * sx) * 3;
ImageA[x,y].r := byte((pPixel + 2)^);
ImageA[x,y].g := byte((pPixel + 1)^);
ImageA[x,y].b := byte((pPixel + 0)^);

{ write back fast to the IC buffer }
byte((pPixel + 2)^) := 255 - ImageA[x,y].r;
byte((pPixel + 1)^) := 255 - ImageA[x,y].g;
byte((pPixel + 0)^) := 255 - ImageA[x,y].b;
end;

ICImagingControl1.DisplayImageBuffer(CurrentBuffer );
CurrentBuffer.Unlock();
end;
__________________
Best regards
Johannes
IC Support

Stefan Geissler
August 22, 2006, 08:19:10
The AviCompressors collection can be used as an array. With the "Count" property you will recieve the number of installed codecs. The "Item" property will recieve the index. Thus you should use a simple "for" loop to enumerate and access the codecs.
You can call AviCompressors.Item[i].ShowPropertyPage() to call the property page of the codec, that is indexed by the variable "i". You can also assign the item to a AviCompressor object:


var
i,selected : integer;
Codec : ICImagingControl.AviCompressor;

Begin
selected := -1;
for i:= 0 to ICImagingcontrol.AviCompressors.Count Do
Begin
if ICImagingcontrol.AviCompressors.Item[i].Name = 'MJPEG Compressor' then
begin
selected := i;
end
End;

if selected > -1 then
begin
Codec := ICImagingcontrol.AviCompressors.Item[i];
Codec.ShowPropertyPage();
end;
end;

Related links are:
http://www.imagingcontrol.com/ic/docs/html/activex/AviCompressors.htm
http://www.imagingcontrol.com/ic/docs/html/activex/prop_descAviCompressors_Count.htm
http://www.imagingcontrol.com/ic/docs/html/activex/prop_descAviCompressors_Item.htm
http://www.imagingcontrol.com/ic/docs/html/activex/AviCompressor.htm

Please excuse some syntax errors in Delphi, I am no Delphi programmer :-)

Stefan Geissler
August 23, 2006, 08:24:24
Hello,

after reading your post again, i found that I misunderstood your request. Saving image buffers into an AVI file is a very interesting theme on its own. I is no IC Imaging Control problem but you should find matching Delphi code in the internet.