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
 Tiling Advice

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
bmesser Posted - Feb 02 2013 : 03:21:17
Hi

I have access to a free web map service that provides tiled 200x200 PNG map images. I have no problem getting at the images which I plan to cache to save me having to download every time the application is run. What I have now is a simple jigsaw of map pieces that I need to put together! I figure that if I aim to display a 5x5 grid of map pieces this will sit nicely on my monitor at a 1000x1000 pixels.

Can anyone advise me on what the best approach I can take to do this?

Because I plan to overlay a route on the map from a GPS file that I've recorded from my mobile phone, I suppose I would have to use an TImageEnVect rather than a TImageEnView maybe?

Bruce.
4   L A T E S T    R E P L I E S    (Newest First)
bmesser Posted - Feb 04 2013 : 03:50:37
Bill

Your code helped a lot. The real life saver was the call to RenderToTIEBitmapEx which I used to assemble the mosaic by grabbing each tile in turn and placing its bitmap in the correct grid position.

Thanks again.

Bruce.
w2m Posted - Feb 03 2013 : 12:38:27
You could try something similar to this... ImageDrawBackground is not required:

function GetAllFiles(AMask: string; AStringList: TStringList): integer;
var
  iSearch: TSearchRec;
  iDirectory: string;
  iCount: integer;
  iFileAttrs: integer;
begin
  iCount := 0;
  iDirectory := ExtractFilePath(AMask);
  iFileAttrs := $23 - faHidden;
  { Find all files }
  if FindFirst(AMask, iFileAttrs, iSearch) = 0 then
  begin
    repeat
      { add the files to the stringlist }
      AStringList.Add(iDirectory + iSearch.name);
      Inc(iCount);
    until FindNext(iSearch) <> 0;
  end;
  { Subdirectories }
  if FindFirst(ADirectory + '*.*', faDirectory, iSearch) = 0 then
  begin
    repeat
      if ((iSearch.Attr and faDirectory) = faDirectory) and (iSearch.name[1] <> '.') then
        GetAllFiles(iDirectory + iSearch.name + '\' + ExtractFileName(AMask), AStringList);
    until FindNext(iSearch) <> 0;
    FindClose(iSearch);
  end;
  Result := iCount;
end;

procedure TForm1.MakeTile;
var
  iBaseWidth: Integer;
  iFilename: string;
  iColumns: Integer;
  x: Integer;
  iFolder: string;
  i: Integer;
  iRows: Integer;
  iHeight: Integer;
  iWidth: Integer;
  iFileCount: Integer;
  iBaseHeight: Integer;
  iFilesList: TStringList;
  y: Integer;
  iPadding: integer;
begin
    Screen.Cursor := crHourGlass;
    try
      iFilesList := TStringList.Create;
      try
        i := -1;
        iFolder := IncludeTrailingPathDelimiter(ShellTreeView1.Path);
        iFileCount := GetAllFiles(iFolder + '*.*', iFilesList);
        StatusBar1.Panels[3].Text := 'Files: ' + IntToStr(iFileCount);
        iPadding := StrToIntDef(Padding1.Text, 6);
        iColumns := StrToIntDef(Columns1.Text, 6);
        iRows := StrToIntDef(Rows1.Text, 12);
        iWidth := StrToIntDef(Height1.Text, 200);
        iHeight := StrToIntDef(Width1.Text, 200);
        iBaseWidth := (iColumns * iWidth) + (iPadding * iColumns);
        iBaseHeight := (iRows * iHeight) + (iPadding * iRows);
        ImageEnVect1.Clear;
        ImageEnVect1.Proc.ImageResize(iBaseWidth, iBaseHeight);
        for x := 0 to iColumns - 1 do
          for y := 0 to iRows - 1 do
          begin
            inc(i);
            if i < iFilesList.Count - 1 then
            begin
              iFilename := iFilesList[i];
              if FileExists(iFilename) then
              begin
                with TIEBitmap.Create do
                begin
                  try
                    Read(iFilename);
                    Resample(iWidth+ iPadding, iHeight+ iPadding);
                    RenderToTIEBitmapEx(ImageEnVect1.IEBitmap, (X * (iWidth + iPadding)) , (Y *
                      (iHeight + iPadding)) , iWidth,
                      iHeight, 0, 0, Width, Height, 255, rfNone);
                  finally
                    Free;
                  end;
                end;
              end;
            end;
          end;
        ImageEnVect1.Update;
      finally
        iFilesList.Free;
      end;
    finally
      Screen.Cursor := crDefault;
    end;
end;

The drawing is very fast!


342.22 KB
William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
bmesser Posted - Feb 03 2013 : 10:41:58
Hi Nigel

I've taken your advice and loaded the tiles into a TImageList. I then put some code into the OnDrawBackground event of my TImageEnView so far without much luck.

This forum has been very helpful to me over the last few months when I required help and I would be lost without its help but there is no mention of this method in the help file, and a search through all the various demos for OnDrawBackground draws a blank as well, even searching this forum returns nothing.

I would have thought the subject of tiling images would be quite common to ask help on but obviously most users must be manipulating individual images rather than building up a mosaic of smaller images as I'm trying to do.

I'll list the code that I've got at the moment - which doesn't work - as you can see I've made no attempt to work out which tile I want to draw at the moment drawing anything would be a plus!

procedure TfmMain.ImageDrawBackground(Sender: TObject; ACanvas: TCanvas; ARect: TRect; var Handled: Boolean);
var
bmp : TBitMap;
begin
bmp:=TBitMap.Create;
bmp.Width:=200;
bmp.Height:=200;

if TileList.GetBitmap(1,bmp) then
begin
ACanvas.Draw(100,100,bmp);
Handled:=True;
end;
end;

Any further help would be appreciated!

Bruce.
xequte Posted - Feb 02 2013 : 13:26:55
Hi Bruce

Handling the drawing of the tiles will be relatively easy. Store the currently active tiles in some type of image list. Whenever you get the OnDrawBackground event of your TImageEnView/TImageEnVect copy the relevant portions of your tile images onto the background canvas:

http://www.imageen.com/help/TIEOnDrawBackground.html

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com