GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
AG_PIXMAP(3) FreeBSD Library Functions Manual AG_PIXMAP(3)

AG_Pixmapagar pixmap display widget

#include <agar/core.h>
#include <agar/gui.h>

The AG_Pixmap widget displays an image in pixmap format. It is commonly used along with AG_Fixed(3) to display interface decorations.

Multiple images may be associated with an AG_Pixmap instance. Animation can be done by mapping frames with () and calling AG_PixmapSetSurface() from an AG_Timer(3) callback or a separate thread.

AG_Object(3) -> AG_Widget(3) -> AG_Pixmap.

AG_Pixmap *
AG_PixmapNew(AG_Widget *parent, Uint flags, Uint width, Uint height);


AG_Pixmap *
(AG_Widget *parent, Uint flags, const AG_Surface *src);


AG_Pixmap *
(AG_Widget *parent, Uint flags, const AG_Surface *src, Uint width, Uint height);


AG_Pixmap *
(AG_Widget *parent, Uint flags, AG_Surface *src);


AG_Pixmap *
(AG_Widget *parent, Uint flags, const char *path);


AG_Pixmap *
(AG_Widget *parent, Uint flags, GLuint texture, int lod);

The () function creates a new AG_Pixmap not linked to any surface. The initial geometry of the widget is defined by the width and height parameters. Acceptable flags include:

AG_PIXMAP_RESCALE
Rescale image to fit widget size.
AG_PIXMAP_HFILL
Expand horizontally in parent container.
AG_PIXMAP_VFILL
Expand vertically in parent container.
AG_PIXMAP_EXPAND
Shorthand for AG_PIXMAP_HFILL | .

The () function creates a new AG_Pixmap widget displaying a copy of the specified surface. A pixel-format conversion is performed if necessary. If the src argument is NULL, an empty surface is displayed. The AG_PixmapFromSurfaceScaled() variant resizes the image to the given dimensions.

The () variant uses the specified surface without making a copy. The provided surface must remain valid as long as the widget exists, and it must be in a format that can be displayed directly (such as agSurfaceFmt).

The () function loads a surface from the image file at path (image type is autodetected).

() may be used to display an active hardware texture. lod specifies the level-of-detail of the texture (level 0 is the base image level). If OpenGL support is not available, an error is returned.

int
AG_PixmapAddSurface(AG_Pixmap *pixmap, const AG_Surface *surface);


int
(AG_Pixmap *pixmap, const AG_Surface *surface, Uint width, Uint height);


int
(AG_Pixmap *pixmap, const char *path);


void
(AG_Pixmap *pixmap, int surface_name);


AG_Surface *
(AG_Pixmap *pixmap, int surface_name);


void
(AG_Pixmap *pixmap, int surface_name, AG_Surface *surfaceNew);


void
(AG_Pixmap *pixmap, int surface_name);


void
(AG_Pixmap *pixmap, int w, int h);


void
(AG_Pixmap *pixmap, int s, int t);

The () functions maps a copy of the specified surface. AG_PixmapAddSurfaceScaled() maps a copy of the given surface, resized to width by height pixels. AG_PixmapAddSurfaceFromFile() maps a surface obtained from an image file (format is autodetected).

() changes the currently displayed surface (see n in STRUCTURE DATA). The argument should be the handle of one of the surfaces previously mapped with AG_PixmapAddSurface().

The () returns a copy of the surface at given index (if the index is invalid then a fatal condition is raised).

The () routine replaces the contents of the specified surface mapping.

If the contents of a currently mapped surface are directly modified, () should be called. This routine may or may not be a no-op depending on the graphics mode.

() requests a specific geometry in pixels. The default geometry is that of the source surface passed to the constructor.

The () function changes the source coordinates of the active surface. The default is [0,0].

The AG_Pixmap widget does not generate any event.

For the AG_Pixmap object:

int n
Handle of currently displayed surface (-1 = none).
int s, t
Source surface coordinates. Can be set using AG_PixmapSetCoords().

The following code fragment displays an existing AG_Surface(3). It packs AG_Pixmap in a AG_Scrollview(3) widget, allowing the user to pan the view:

AG_Scrollview *sv;
AG_Pixmap *px;

sv = AG_ScrollviewNew(window, AG_SCROLLVIEW_BY_MOUSE |
                              AG_SCROLLVIEW_EXPAND);

px = AG_PixmapFromSurface(sv, 0, mySurface);

The following code fragment displays some image files:

AG_PixmapFromFile(sv, 0, "foo.png");
AG_PixmapFromFile(sv, 0, "bar.jpg");

The following code fragment loads 30 frames in JPEG format:

char path[AG_FILENAME_MAX];
AG_Pixmap *px;
int frames[30];
int i;

px = AG_PixmapNew(win, 0, 320,240);
for (i = 0; i < 30; i++) {
	AG_Snprintf(path, sizeof(path), "%08d.jpg", i);
	frames[i] = AG_PixmapAddSurfaceFromFile(px, path);
}

Running from a separate thread, the following code fragment would play back the animation:

for (i = 0; i < 30; i++) {
	AG_PixmapSetSurface(px, frames[i]);
	AG_Delay(10);
}

AG_Fixed(3), AG_Intro(3), AG_Scrollview(3), AG_Surface(3), AG_View(3), AG_Widget(3), AG_Window(3)

See tests/fixedres.c in the Agar source distribution.

The AG_Pixmap widget first appeared in Agar 1.0. AG_PixmapGetSurface() appeared in Agar 1.6.0.

December 21, 2022 Agar 1.7

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.