ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TIEMediaReader Error
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

wesleybobato

Brazil
367 Posts

Posted - Jan 18 2013 :  09:25:27  Show Profile  Reply
Hello Nigel Below is the code giving an error.
Invalid floating point operation at the Next Function.
TIEMediaReader.GetSample procedure (frame: int64; OutBitmap: TIEBitmap);
In this line fMediaDet.GetBitmapBits (frame / fFrameRate, nil, fFrameBuffer, fFrameWidth, fFrameHeight);
is because it is a division by zero 0.


var media:TIEMediaReader;
begin
media := TIEMediaReader.Create(ImageEnView1.IO.ExecuteOpenDialog);

// get frame 0 and save to sample0.jpeg
media.GetSample( 0, ImageEnView1.IEBitmap );
ImageEnView1.IO.SaveToFile('sample0.jpeg');

// get frame 1 and save to sample1.jpeg
media.GetSample( 1, ImageEnView1.IEBitmap );
ImageEnView1.IO.SaveToFile('sample1.jpeg');


media.free;

fab

1310 Posts

Posted - Jan 22 2013 :  10:40:36  Show Profile  Reply
Actually TIEMediaReader has a bug. To fix it open ieds.pas and locate TIEMediaReader.GetSample method. Now replace it with:

procedure TIEMediaReader.GetSample(frame:int64; OutBitmap:TIEBitmap);
var
  bf: integer;
  frameBuffer: pointer;
begin
  fMediaDet.GetBitmapBits(frame / fFrameRate, @bf, nil, fFrameWidth, fFrameHeight);
  GetMem(frameBuffer, bf);
  try
    fMediaDet.GetBitmapBits(frame / fFrameRate, nil, frameBuffer, fFrameWidth, fFrameHeight);
    OutBitmap.CopyFromDIB(frameBuffer);
  finally
    freemem(frameBuffer);
  end;
end;


The complete fix will be available in next release.
Go to Top of Page

fab

1310 Posts

Posted - Jan 22 2013 :  10:41:41  Show Profile  Reply
With that fix you can use TIEMediaReader to add images in TImageEnMView:

var
  media: TIEMediaReader;
  bmp: TIEBitmap;
  idx: integer;
begin
  media := TIEMediaReader.Create('test.wmv');
  idx := ImageEnMView1.AppendImage(100, 100);
  bmp := ImageEnMView1.GetTIEBitmap(idx);
  media.GetSample(0, bmp);
  ImageEnMView1.ReleaseBitmap(idx);
  media.Free();
end;
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - Jan 22 2013 :  13:32:01  Show Profile  Reply
Thank Fabricio a Big Hug
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: