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
 Saving Image and DrawBackBuffer
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
236 Posts

Posted - Jan 07 2015 :  11:51:18  Show Profile  Reply
Hi

I am using slippy maps with a TImageEnView component to display a map which I then draw contours on using the DrawBackBuffer.

I would like to save an exact copy of the map with the contours but when I do, I only get the map.

Is there any easy way that I can consolidate both the map and what I've drawn on the map and save or print it in its entirety?

Bruce.

xequte

39140 Posts

Posted - Jan 07 2015 :  15:58:32  Show Profile  Reply
Hi Bruce

Why not copy the map to a bitmap, and then use your DrawBackBuffer code to draw the same data onto the bitmap (i.e. one method that takes a TCanvas that is used by both methods).

Then print the bitmap.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

bmesser

United Kingdom
236 Posts

Posted - Jan 09 2015 :  10:51:27  Show Profile  Reply
Nigel

Thanks for the suggestion, but I had no luck when trying this code to grab the bitmap:


    bmp.Width:=Image.ClientWidth;
    bmp.Height:=Image.ClientHeight;
    bmp.PixelFormat:=pf24bit;
    Image.CopyToBitmapWithAlpha(bmp,0,0);


All I got was a white bitmap. Isn't the map some kind of virtual image and that's why I can't grab it or is it me?

In the mean time I'm using this Windows call which seems to do the trick, but obviously it would be better if I could just grab the map and the backbuffer straight from the slippymap component.


    bmp.Width:=Image.ClientWidth;
    bmp.Height:=Image.ClientHeight;
    bmp.PixelFormat:=pf24bit;

    bmp.Canvas.CopyRect(Rect(0,0,Image.Width,Image.Height),Canvas,Rect(
      Image.ClientOrigin.X,
      Image.ClientOrigin.Y,
      Image.ClientOrigin.X+Image.ClientWidth,
      Image.ClientOrigin.Y+Image.ClientHeight));


Bruce.
Go to Top of Page

xequte

39140 Posts

Posted - Jan 10 2015 :  14:21:44  Show Profile  Reply
Hi Bruce

What is "Image" in this code?

You should be able to just assign the image of TImageEnView.IEBitmap, e.g. bmp.Assign( ImageEnView1.IEBitmap.VclBitmap );

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

bmesser

United Kingdom
236 Posts

Posted - Jan 11 2015 :  05:01:11  Show Profile  Reply
Nigel

Image is a TImageEnView that I'm using for a slippy map container. Don't forget you have to assign a virtual bitmap provider:

Image.IEBitmap.VirtualBitmapProvider:=Map;


If I run your code and save the contents to a bitmap file its saves an empty (0k) bitmap file.

Bruce.
Go to Top of Page

xequte

39140 Posts

Posted - Jan 11 2015 :  15:21:33  Show Profile  Reply
Hi Bruce

Even if it is a virtual bitmap, the IEBitmap should still have content.

  aBmp := TBitmap.create;
  ImageEnView1.iebitmap.CopyToTBitmap( aBmp );
  // Do something with aBmp
  aBmp.Free;


But, now I think about it, if you have drawn to ImageEnView1.BackBuffer, why not just print ImageEnView1.BackBuffer? (there is a TBitmap print helper method in iexHelperFunctions).


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

bmesser

United Kingdom
236 Posts

Posted - Jan 12 2015 :  10:12:42  Show Profile  Reply
Nigel

That last method you suggested worked:

ImageEnView1.iebitmap.CopyToTBitmap( aBmp );


which is strange because your previous suggestion

bmp.Assign( ImageEnView1.IEBitmap.VclBitmap );


didn't, neither did the one I initially tried.

Image.CopyToBitmapWithAlpha(bmp,0,0)
;

I then passed the bitmap canvas onto my contouring routine and voila!

I don't pretend to understand why that method works and the others bring back an empty or blank bitmap.

Thanks a lot.

Bruce.
Go to Top of Page

xequte

39140 Posts

Posted - Jan 12 2015 :  18:10:57  Show Profile  Reply
Hi Bruce

You didn't try the backbuffer which should already have your custom drawn content?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: