Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » TopWindow content to image
TopWindow content to image [message #26511] Fri, 07 May 2010 10:53 Go to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
Hello,

how to get the content of the TopWindow after whole refreshing to image? (mainly for printing purposes)

topwindow has only custom image-ctrls with many alpha images in it

thank you.

Re: TopWindow content to image [message #26518 is a reply to message #26511] Fri, 07 May 2010 14:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Usually, you do this by implementing the actual rendering process in some other routine than Paint. Paint then just calls this routine; often you will want to parametrize a bit so what is going to screen is different from what is going to printer.

Then, if you are about to print, just use Draw obtained from PrinterJob (and the one you get in Paint for screen).

Sort of example can be found in UWord; but you will have to dig quite deep: In fact, rendering is implemented by RichText class there, and used for printer and for screen by RichEdit.
Re: TopWindow content to image [message #26519 is a reply to message #26518] Fri, 07 May 2010 16:02 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
thank you for reply.

printing: yes, I've did it like that. I am drawing something in the paint routine and something somewhere else.

the stuff in paint routine for printing is(there was need for some scaling etc.)

other visual stuff is broke.

1. I have custom image-ctrls, which I am adding to screen, moving with them, they are composed of some alpha images, I can move with them, works fine.

2. in paint routine, the only thing I am doing, is setting rectangle for every of these images apparent to their size and possition.

3. I am calling timer(20 per sec) to call some needed stuff and there is also a Refresh()


When the event to print comes to scene, all the custom (the only at all) image-ctrls(have just one type) is situated in one place in lefttop.

I will try to put here some shortened example.
nice week

[Updated on: Fri, 07 May 2010 19:04]

Report message to a moderator

Re: TopWindow content to image [message #26530 is a reply to message #26519] Mon, 10 May 2010 08:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
qwerty wrote on Fri, 07 May 2010 10:02

thank you for reply.

printing: yes, I've did it like that. I am drawing something in the paint routine and something somewhere else.

the stuff in paint routine for printing is(there was need for some scaling etc.)

other visual stuff is broke.

1. I have custom image-ctrls, which I am adding to screen, moving with them, they are composed of some alpha images, I can move with them, works fine.

2. in paint routine, the only thing I am doing, is setting rectangle for every of these images apparent to their size and possition.

3. I am calling timer(20 per sec) to call some needed stuff and there is also a Refresh()


When the event to print comes to scene, all the custom (the only at all) image-ctrls(have just one type) is situated in one place in lefttop.

I will try to put here some shortened example.
nice week


OK. Well, generally, it can be a bit tricky to print widgets. But I will wait for the example Smile

Mirek
Re: TopWindow content to image [message #26533 is a reply to message #26530] Mon, 10 May 2010 10:46 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
class SegImage_t {
public:
	Image img;
        ...

	SegImage_t(String fn, byte B_) : B(B_) {
                ...
		img = StreamRaster::LoadFileAny(~fn);
                ...
	}
};


class SegItem : public Ctrl {
	typedef SegItem CLASSNAME;

	WithPropsLay<TopWindow> propsWin;

public:
	q* owner;

        ...

	Array<SegImage_t> segs;
	SegItem(String fn, int id, q* owner);

        ...

        void Paint(Draw& w) {
                ...

        	w.DrawImage(GetSize(), back);
	        for(int i = 0; i < segs.GetCount(); ++i) {
			w.DrawImage(GetSize(), segs[i].img);
		}

                ...
        };



class q : public TopWindow {
private:
	typedef q CLASSNAME;

	WithOptLay<TopWindow> optWin;

public:

	Array<SegItem> segitems;
	SegItem*       segitem;

        ...

        void Paint(Draw& w) {
                paint(w);
        }

        paint(Draw& w) {
	        w.DrawRect(GetSize(), Black);

                ...

        	for(int s = 0; s < segitem.segs.GetCount(); ++s) {
                    segitem.SetRect(
			x, y,
			segitem.segs[s].img.GetWidth (),
			segitem.segs[s].img.GetHeight()
		);
 
                ...

	}

        void rs32Proc() {

                ...

                Refresh();
        }

        Print() {
                // ...simplified...

                PrinterJob pj;

	        pj.Landscape();

                Draw& w = pj;
                w.StartPage();

                paint(w);
	       
                w.EndPage();
        }


        q() {
                ...
                
                SetTimeCallback(REFRESH_TIME, THISBACK(rs232Proc));

        }
};



when I try to print it, all the SegItems is in left-top corner. In real, they have differrent coordinates. Can make some custom print routine, but why to separate? Smile

thank you

[Updated on: Mon, 10 May 2010 10:47]

Report message to a moderator

Re: TopWindow content to image [message #26535 is a reply to message #26533] Mon, 10 May 2010 10:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, such example is not really helpful, anything can be wrong. Would it be possible to provide a complete testcase please?

Important note: Host platform based widgets (those painted using hostplatform Api, like Button in Win32) are unlikely to work well when printing.

Just to be sure, are you aware about coordinate differences when printing? (1 pixel is 1/600inch big on printer - "dot").
Re: TopWindow content to image [message #26537 is a reply to message #26535] Mon, 10 May 2010 12:00 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
I am sorry, but about coordinates I am not. I must experimenting every time.

thing about printing/viewing. just to take screenshot... how about that? and then simply scale and send to printer... ?

thoughts is twisting about the idea of own rutine to check and scale screen to fit the page automatically btw.

you are telling, that the printing ctrls is tricky...
how it should be right? (if it even could be)
the array of Added(SegItem)s ctrls is the only I have created and using.

I will attach the whole project, if it helps, but it's 'big'

ps: I had copied the code only relevant to ctrls, everything else is about background stuff etc. nothing to do w/ visuals

pps: I was thinking about 'catch' the block of memory somewhere which has to be printed to videobuffer and dump it

[Updated on: Mon, 10 May 2010 12:19]

Report message to a moderator

Re: TopWindow content to image [message #26538 is a reply to message #26537] Mon, 10 May 2010 13:04 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello qwerty

I also strongly suggest you to do a small standalone test case.

I understand it will cost you some time, but for some problems it is the only way to let others to help you Smile.

It served for me other times in the past.


Best regards
IƱaki
Re: TopWindow content to image [message #26539 is a reply to message #26537] Mon, 10 May 2010 13:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Maybe you can can create simplified testcase demonstrating the problem, as separate project.....

Mirek
Re: TopWindow content to image [message #26595 is a reply to message #26539] Fri, 14 May 2010 08:41 Go to previous messageGo to next message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
hello,

thank you for your responses. I had some issues, that need's to be solved. I will try to derive some testcase and 'test' that it to works same wrong way as my program works Smile

thank you so far, need time Smile
Re: TopWindow content to image [message #26659 is a reply to message #26595] Tue, 18 May 2010 11:23 Go to previous message
qwerty is currently offline  qwerty
Messages: 130
Registered: May 2006
Experienced Member
hello again.

I will freeze this topic for now. I am going to finish other tasks to use the program(because it's needed) and topic here discused later.

hope I don't upset you.

thank you very much
Previous Topic: Access Animated GIF ??
Next Topic: Image: Rescale proportional propose:
Goto Forum:
  


Current Time: Fri Mar 29 15:30:28 CET 2024

Total time taken to generate the page: 0.01752 seconds