如果用TMEDIAPLAYER控件,可以用DisplayRect来实现,播放画面的坐标,现在用DSPACK怎么实现啊?我想播放指定区域的图象,例如播放坐标为“0,0,高度,宽度”,谢谢知道的提供下

解决方案 »

  1.   

    使用SampleGrabber,拷贝图像
    然后就是canvas的操作
      

  2.   

    知道大概了,谢谢啊
    procedure TForm1.SampleGrabberBuffer(sender: TObject; SampleTime: Double;
      pBuffer: Pointer; BufferLen: Integer);
    begin
      if CallBack.Checked then
      begin
        Image.Canvas.Lock; // to avoid flickering
        try
          SampleGrabber.GetBitmap(Image.Picture.Bitmap, pBuffer, BufferLen)
        finally
          Image.Canvas.Unlock;
        end;
      end;
    end;
    另外,还想问问canvas的操作,用哪个函数控制显示画面的区域,我只要显示指定的坐标的。怎么实现啊
      

  3.   

    procedure TfrmPlay.copyimage( tpb:timage; SampleTime: Double; pBuffer:
      Pointer; BufferLen: Integer);
    var
      gd,kd:integer;
      gdb,kdb:integer;
      rc1:trect;
      //cd:integer;
      //strsj:string;
      x,y:real;//空白比例
    begin
      //拷贝图像
      //  hxh 2006-12-12
      //由于lock  编译状态下可以,直接运行exe不可以  郁闷
      //内存中  image就行
      //tpa.Canvas.Unlock;
      //if self.isdrawing then exit;
      //self.isdrawing:=true;
      if self.issize then
      begin
        tp.Picture:=nil;
        self.issize:=false;
      end;  //tpb.Picture:=nil;
      tpa.Canvas.lock;
      tpb.Canvas.Lock;
      //tpb.Canvas.Lock;
      //tpb.Canvas.Lock;
      try
        //image.Picture:=nil;
        //tpa.Canvas.Lock;                // to avoid flickering    SampleGrabber.GetBitmap(tpa.Picture.Bitmap, pBuffer, BufferLen);
        //tpa.Canvas.Unlock;
        //tpa.Canvas.Unlock;
        //tpa.Canvas.Unlock;
        //draw my text.by s.f.
        //cd := Image.Picture.Bitmap.Canvas.TextWidth('hello');
        //if (OffsetX + textLength) > 0 then
        //tpa.Canvas.Brush.Style := bsClear;
        //tpa.Canvas.Font.Color := clRed;
        //tpa.Canvas.TextOut(100, 10, 'hello中国海军');
        //tpa.Canvas.TextOut(100, 50, datetimetostr(now));
        //tpa.Canvas.Pen.Color:=clgreen;
        //tpa.Canvas.Rectangle(20,20,50,50);
        //Dec(OffsetX, 1);
        //exit;    gd:=tpa.Height;
        kd:=tpa.Width;
        gdb:=round(gd/2);
        kdb:=round(kd/2);
        //左边,中间,有白边
        x:=0.035;
        y:=0.01;
        if bf=1  then
        begin
          //左上
          rc1:=rect(round(kdb*x),round(gdb*y),kdB,round(gdB*(1-y)));
        end
        else  if bf=2 then
        begin
          rc1:=rect(round(kdb*(1+x)),round(gdb*+y),kd,round(gdB*(1-y)));
        end
        else if bf=3  then
        begin
          //左下
          rc1:=rect(round(kdb*x),round(gdb*(1+y)),kdb,round(gdB*(2-2*y)));
        end
        else  if bf=4 then
        begin
          rc1:=rect(round(kdb*(1+x)),round(gdb*(1+y)),kd,round(gdB*(2-2*y)));
        end
        else  if bf=5 then
        begin
          rc1:=rect(0,0,kd,gd);
        end;
        //tpb.Canvas.Lock;
        //tpb.Canvas.Lock;
        //tpb.Canvas.Lock;
        //tpb.Picture:=nil;    tpb.Canvas.CopyRect(tpb.BoundsRect,tpa.Canvas,rc1);
        {
        //文字
        tpb.Canvas.font.Color:=cllime;
        tpb.Canvas.Font.Size:=12;
        cd:=tpb.Canvas.TextWidth('文件:'+self.filetitle);
        tpb.Canvas.Brush.Style:=bsclear;
        tpb.Canvas.TextOut(tpb.Width-cd-30,20,'文件:'+self.filetitle);
        if self.begintime<>0 then
        begin
          strsj:='开始时间:'+FormatDateTime('yyyy-mm-dd hh:nn:ss',self.begintime);
          cd:=tpb.Canvas.TextWidth(strsj);
          tpb.Canvas.TextOut(tpb.Width-cd-30,40,strsj);
        end;
        }
        //tp2.Canvas.font.Color:=cllime;
        //tp2.Canvas.Font.Size:=12;
        //tp2.Canvas.TextOut(10,20,'文件:'+self.filetitle);
        //tp2.Canvas.TextOut(10,10,'hello中国海军');
        //tp2.Canvas.TextOut(10,40,strsj);
        //tpb.Canvas.Unlock;
        //tpb.Canvas.Unlock;
        //tpb.Canvas.Unlock;
        //IMAGE.Canvas.CopyRect(tp.ClientRect,TP.Canvas,rc1);
      finally
        //tpa.Canvas.Unlock;
        tpb.Canvas.Unlock;
        tpa.Canvas.unlock;    //tpa.Free;
      end;
      //self.isdrawing:=false;
    end;