Re: [BLACKBOX] YNT: [BLACKBOX] Producing .PNG file

From: [at]} <Robert>
Date: Sat, 7 Feb 2009 10:46:46 +0000

----boundary-LibPST-iamunique-1495879632_-_-
Content-type: text/plain

Hi

I wrote something almost exactly the same some time ago
(actually I copied HostBitmaps.ViewToBitmap rather than
HostBitmaps.TurnToBitmap, but they seem to be very similar).

A problem I initially had was if the View being converted was not in a Container.

The line:
   v.context.GetSize(w, h);
causes a TRAP. For this case I added the code:


VAR
   text : TextModels.Model;
   wr : TextModels.Writer;
BEGIN
...
   IF v.context = NIL THEN
     text := TextModels.dir.New ();
     wr := text.NewWriter (NIL);
     wr.WriteView (v, Views.undefined, Views.undefined)
   END;
   v.context.GetSize(w, h);


Some Views do not convert well. The obvious example is a Form
with user interaction Controls (try printing such a View - terrible!).

For such Views a more successful approach is to do a pixel-by-pixel
screen grab. I can post example code if anyone requires it - but NO
GUARANTEES that I am doing all the correct WinApi calls in the correct order.

Anyway - thanks to Necati for the FreeImage interface - very useful.

Regards

Robert


F. Necati Ecevit wrote:
> If I understand correctly, you would like to save your graph view as
> image file ?
>
> if you have a handle to your view, it is possible to convert this view
> to FIBITMAP and save to png file.
> For example, in ObxTickers's HandleModelMsg, after Views.Update(..)
> store the view as png file, current snapshot of view by using
> FreeViewToImage.StoreViewAsImage(v,"test.png",24,0).
>
> Here, I attached FreeViewToImage module to convert any view (Views.View
> extension) to FIBITMAP or store the view to file as png file.
>
> I hope it helps,
>
> Regards,
>
> - Necati.
>
>
> StdCoder.Decode KZKNrFpP7pKMbJa9jFqM..,0 1Ak...VB,...58FTuPE,5TW
 > ...


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1495879632_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d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IfX0Ac3Vycg==
----boundary-LibPST-iamunique-1495879632_-_---
Received on Sat Feb 07 2009 - 11:46:46 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:49 UTC