Generating and print a bitmap

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Generating and print a bitmap

Christoph J. Bachinger
Hello,

I've a problem
with generating a bitmap from the open window.
How does it work?

And how can I print it then?

I also have to deposit the function 'print' in my DefaultView,
how can I invoke this?

Thank you for help,

mfg
Katjana


Reply | Threaded
Open this post in threaded view
|

Re: Generating and print a bitmap

Christopher J. Demers
"Katjana T." <[hidden email]> wrote in message
news:[hidden email]...
> I've a problem
> with generating a bitmap from the open window.
> How does it work?

See the code bellow for one way, there may be better ways.  I did this
quickly.
==============
"Create and open a view."
v := (ListPresenter show) view.
v model: (ListModel on: #('aaa' 'bbb' 'ccc')).
pv := v topShell.
pv extent: 100 @ 100.

"Evaluate this separately after the view is opened."
canvas := pv canvas.
bitmap := Bitmap compatible: canvas extent: pv clientExtent.
bmCanvas := bitmap canvas.
bmCanvas backcolor: Color white.
bmCanvas erase.
bmCanvas bitBlt: pv canvas rectangle: pv clientRectangle
to: 0@0 rop: (Integer fromString: '16rCC0020').
bitmap inspect.
==============

> And how can I print it then?

Instead of a Canvas as used above I imagine you could use a PrinterCanvas.

> I also have to deposit the function 'print' in my DefaultView,
> how can I invoke this?

Add a command to the menu, and then add a similarly named method to the
presenter class.  Visit the Education Center (
http://www.object-arts.com/EducationCentre/Education.htm ) to learn more and
look at some tutorials.

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Generating and print a bitmap

Bill Schwab-2
> > And how can I print it then?
>
> Instead of a Canvas as used above I imagine you could use a PrinterCanvas.

You imagine correctly :)  Resolution will be higher on the printer, so a
stretching variant of #drawOn: will probably be necessary.  If you can
generate higher resolution graphics for the printer vs. capturing and
stretching it indirectly from the screen, that will be better, but it might
be that you really want to print screen dumps, in which case stretching is
the best you can do.

PrinterCanvas will require you to call #startDoc and #endDoc (when done)
once per document, and #startPage and #endPage once per page.  IIRC, Ian has
some goodies that print.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]