1 //Copyright Paul Reiche, Fred Ford. 1992-2002
2 
3 /*
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 
19 #include "libs/gfxlib.h"
20 #include "libs/graphics/drawable.h"
21 #include "libs/log.h"
22 
23 
24 // Reads a piece of screen into a passed FRAME or a newly created one
25 DRAWABLE
LoadDisplayPixmap(const RECT * area,FRAME frame)26 LoadDisplayPixmap (const RECT *area, FRAME frame)
27 {
28 	// TODO: This should just return a FRAME instead of DRAWABLE
29 	DRAWABLE buffer = GetFrameParentDrawable (frame);
30 	COUNT index;
31 
32 	if (!buffer)
33 	{	// asked to create a new DRAWABLE instead
34 		buffer = CreateDrawable (WANT_PIXMAP | MAPPED_TO_DISPLAY,
35 				area->extent.width, area->extent.height, 1);
36 		if (!buffer)
37 			return NULL;
38 
39 		index = 0;
40 	}
41 	else
42 	{
43 		index = GetFrameIndex (frame);
44 	}
45 
46 	frame = SetAbsFrameIndex (CaptureDrawable (buffer), index);
47 
48 	if (_CurFramePtr->Type != SCREEN_DRAWABLE
49 			|| frame->Type == SCREEN_DRAWABLE
50 			|| !(GetFrameParentDrawable (frame)->Flags & MAPPED_TO_DISPLAY))
51 	{
52 		log_add (log_Warning, "Unimplemented function activated: "
53 				"LoadDisplayPixmap()");
54 	}
55 	else
56 	{
57 		TFB_Image *img = frame->image;
58 		TFB_DrawScreen_CopyToImage (img, area, TFB_SCREEN_MAIN);
59 	}
60 
61 	ReleaseDrawable (frame);
62 
63 	return buffer;
64 }
65 
66