码迷,mamicode.com
首页 > 其他好文 > 详细

Imageen 图像切割 (JpegLosslessTrans)

时间:2017-01-20 23:18:04      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:proc   length   文件名   taf   nal   query   top   sles   oms   

procedure CutAFile(FileName: string; qry: TQuery);
var
  i: Cardinal;
  FromStream, ToStream: TMemoryStream;
  SubFileName, Path, fName, MainName, ExtName: string;
  NewFileName, Sub_PicName, TemplateName: string;
  r: TRect;
begin
  if Not FileExists(FileName) then Exit;

  ExtName := ExtractFileExt(FileName);
  fName := ExtractFileName(FileName);                               //提取文件名
  MainName := copy(fName, 1, length(fName) - Length(ExtName));
  TemplateName  := RightStr(MainName, 6);
  Path := ExtractFilepath(FileName) + TemplateName + ‘\‘;
  FromStream := TMemoryStream.Create;
  FromStream.LoadFromFile(FileName);
  ToStream := TMemoryStream.Create;

  i := 0; // 图像块号
  qry.First;

  while not qry.Eof do begin
    i := i + 1;
    NewFileName := MainName + Format(‘_%0.2d‘, [i]);
    Sub_PicName := NewFileName + ExtName;
    SubFileName := Path + format(‘%0.2d\‘, [i]) + Sub_PicName;

    with qry do begin
      r.Left   := FieldByName(‘selX1‘).AsInteger;
      r.Top    := FieldByName(‘selY1‘).AsInteger;
      r.Right  := FieldByName(‘selX2‘).AsInteger;
      r.Bottom := FieldByName(‘selY2‘).AsInteger;
      FromStream.Position := 0;
      ToStream.Position := 0;
      // JpegLosslessTransform(FileName,SubFileName,jtCut,False,jcCopyAll,r);
      JpegLosslessTransformStream(FromStream,ToStream,jtCut,False,jcCopyAll,r);
      ToStream.Position := 0;
      ToStream.SaveToFile(SubFileName);
      Next;
    end;
  end;

  FromStream.Free;
  ToStream.Free;
end;

Imageen 图像切割 (JpegLosslessTrans)

标签:proc   length   文件名   taf   nal   query   top   sles   oms   

原文地址:http://www.cnblogs.com/yzryc/p/6329464.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!