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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 save page range in TImageEnMView

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jccode Posted - Sep 27 2012 : 07:25:42
I need to save a page range to file (tiff) in the TImageEnMView. Is there a way to do this. Say I want to save pages 3 through 7 of a 10 page document without deleting any images from the view.

Thanks for your help.
4   L A T E S T    R E P L I E S    (Newest First)
jccode Posted - Sep 27 2012 : 18:47:21
I now see there are begin and end select images statements. Thanks very much for the source code. This will be very helpful.
w2m Posted - Sep 27 2012 : 17:35:41
function SplitStr(const AString: string; ADelim: Char; out AString1, AString2: string): boolean;
// Splits the string S at the first occurence of delimiter character Delim and
// sets AString1 to the sub-string before Delim and AString2 to substring following Delim. If
// Delim is found in string True is returned, while if Delim is not in string
// False is returned, AString1 is set to AString and AString2 is set to ''.
var
  DelimPos: integer; // position of delimiter in source string
begin
  // Find position of first occurence of delimter in string
  DelimPos := SysUtils.AnsiPos(ADelim, AString);
  if DelimPos > 0 then
  begin
    // Delimiter found: do split and return True
    AString1 := Copy(AString, 1, DelimPos - 1);
    AString2 := Copy(AString, DelimPos + 1, MaxInt);
    Result := True;
  end
  else
  begin
    // Delimeter not found: return false and set S1 to whole string
    AString1 := AString;
    AString2 := '';
    Result := False;
  end;
end;

function ExplodeStr(AString: string; const ADelim: Char; const AList: Classes.TStrings;
  const AAllowEmpty: boolean = True; const ATrim: boolean = False): integer;
// Splits the string S into a list of strings, separated by Delim, and returns
// the number of strings in the list. If AllowEmpty is true then any empty
// strings are added to the list, while they are ignored if AllowEmpty is false.
// If Trim is true strings have leading and trailing spaces removed.
var
  Item: string; // current delimted text
  Remainder: string; // remaining unconsumed part of string
  // ---------------------------------------------------------------------------

  procedure AddItem;
  begin
    // Adds optionally trimmed item to list if required
    if (ATrim) then
      Item := SysUtils.Trim(Item);
    if (Item <> '') or AAllowEmpty then
      AList.Add(Item);
  end;
  // ---------------------------------------------------------------------------

begin
  // Clear the list
  AList.Clear;
  // Check we have some entries in the string
  if AString <> '' then
  begin
    // Repeatedly split string until we have no more entries
    while SplitStr(AString, ADelim, Item, Remainder) do
    begin
      AddItem;
      AString := Remainder;
    end;
    // Add any remaining item
    AddItem;
  end;
  Result := AList.Count;
end;


object FormSelectImages: TFormSelectImages
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Select Images'
ClientHeight = 107
ClientWidth = 421
Color = clWindow
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poOwnerFormCenter
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 75
Width = 421
Height = 32
Align = alBottom
BevelOuter = bvNone
Caption = 'Panel1'
ParentBackground = False
ShowCaption = False
TabOrder = 0
ExplicitTop = 457
ExplicitWidth = 601
object Ok1: TButton
Left = 6
Top = 4
Width = 75
Height = 25
Caption = 'Ok'
ModalResult = 1
TabOrder = 0
end
object Cancel1: TButton
Left = 87
Top = 4
Width = 75
Height = 25
Caption = 'Cancel'
ModalResult = 2
TabOrder = 1
end
end
object GroupBox1: TGroupBox
Left = 8
Top = 8
Width = 395
Height = 61
Caption = 'Selections'
TabOrder = 1
object Selections1: TEdit
Left = 18
Top = 24
Width = 365
Height = 21
TabOrder = 0
Text = '1,3,5'
end
end
end

procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  iStringList: TStringList;
  iCount: integer;
  s: integer;
begin
  FormSelectImages := TFormSelectImages.Create(self);
  try
    if FormSelectImages.ShowModal = mrOk then
    begin
      ImageEnMView1.DeSelect;
      ImageEnMView1.BeginSelectImages;
      iStringList := TStringList.Create;
      iCount := ExplodeStr(FormSelectImages.Selections1.Text, ',', iStringList, false, true);
      for i := 0 to iCount - 1 do
      begin
          s := StrToInt(iStringList[i]);
          ImageEnMView1.SelectedImage := s;
      end;
      iStringList.Free;
      ImageEnMView1.EndSelectImages;
    end;
  finally
    FormSelectImages.Free;
  end;
end;


The string in FormSelectImages.Selections1 (a TEdit) in the test was 1,3,5. This selects images 1,3 and 5 in the ImageEmMView.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
jccode Posted - Sep 27 2012 : 15:10:20
I should have clarified I want to save a page range in code. Not by selecting manually. Thanks.
w2m Posted - Sep 27 2012 : 13:52:37
This is pretty easy because the file format is ioTIFF.
1. Set ImageEnMView1.EnableMultiselect to True
2. Select the images in ImageEnMView with CTRL or SHIFT Click
3. Call ImageEnMView1.MIO.SaveToFileTIFF(SavePictureDialog1.FileName, True);

procedure ImageEnMView1.MIO.SaveToFileTIFF(const FileName:string;
  SaveSelected:boolean=false);

SaveToFileTIFF saves a multi-image file as TIFF format.
FileName is the file name with extension.
SaveSelected only selected pages are saved if SaveSelected is true. All pages are saved if SaveSelected is omitted or if SaveSelected is False.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html