📄 newgal.h
字号:
/* * Sets the color key (transparent pixel) in a blittable surface. * If 'flag' is GAL_SRCCOLORKEY (optionally OR'd with GAL_RLEACCEL), * 'key' will be the transparent pixel in the source image of a blit. * GAL_RLEACCEL requests RLE acceleration for the surface if present, * and removes RLE acceleration if absent. * If 'flag' is 0, this function clears any current color key. * This function returns 0, or -1 if there was an error. */extern int GAL_SetColorKey (GAL_Surface *surface, Uint32 flag, Uint32 key);/* * This function sets the alpha value for the entire surface, as opposed to * using the alpha component of each pixel. This value measures the range * of transparency of the surface, 0 being completely transparent to 255 * being completely opaque. An 'alpha' value of 255 causes blits to be * opaque, the source pixels copied to the destination (the default). Note * that per-surface alpha can be combined with colorkey transparency. * * If 'flag' is 0, alpha blending is disabled for the surface. * If 'flag' is GAL_SRCALPHA, alpha blending is enabled for the surface. * OR:ing the flag with GAL_RLEACCEL requests RLE acceleration for the * surface; if GAL_RLEACCEL is not specified, the RLE accel will be removed. */extern int GAL_SetAlpha (GAL_Surface *surface, Uint32 flag, Uint8 alpha);/* * Sets the clipping rectangle for the destination surface in a blit. * * If the clip rectangle is NULL, clipping will be disabled. * If the clip rectangle doesn't intersect the surface, the function will * return GAL_FALSE and blits will be completely clipped. Otherwise the * function returns GAL_TRUE and blits to the surface will be clipped to * the intersection of the surface area and the clipping rectangle. * * Note that blits are automatically clipped to the edges of the source * and destination surfaces. */extern GAL_bool GAL_SetClipRect (GAL_Surface *surface, GAL_Rect *rect);/* * Gets the clipping rectangle for the destination surface in a blit. * 'rect' must be a pointer to a valid rectangle which will be filled * with the correct values. */extern void GAL_GetClipRect (GAL_Surface *surface, GAL_Rect *rect);/* * Creates a new surface of the specified format, and then copies and maps * the given surface to it so the blit of the converted surface will be as * fast as possible. If this function fails, it returns NULL. * * The 'flags' parameter is passed to GAL_CreateRGBSurface() and has those * semantics. You can also pass GAL_RLEACCEL in the flags parameter and * GAL will try to RLE accelerate colorkey and alpha blits in the resulting * surface. * * This function is used internally by GAL_DisplayFormat(). */extern GAL_Surface *GAL_ConvertSurface (GAL_Surface *src, GAL_PixelFormat *fmt, Uint32 flags);/* * This performs a fast blit from the source surface to the destination * surface. It assumes that the source and destination rectangles are * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire * surface (src or dst) is copied. The final blit rectangles are saved * in 'srcrect' and 'dstrect' after all clipping is performed. * If the blit is successful, it returns 0, otherwise it returns -1. * * The blit function should not be called on a locked surface. * * The blit semantics for surfaces with and without alpha and colorkey * are defined as follows: * * RGBA->RGB: * GAL_SRCALPHA set: * alpha-blend (using alpha-channel). * GAL_SRCCOLORKEY ignored. * GAL_SRCALPHA not set: * copy RGB. * if GAL_SRCCOLORKEY set, only copy the pixels matching the * RGB values of the source colour key, ignoring alpha in the * comparison. * * RGB->RGBA: * GAL_SRCALPHA set: * alpha-blend (using the source per-surface alpha value); * set destination alpha to opaque. * GAL_SRCALPHA not set: * copy RGB, set destination alpha to opaque. * both: * if GAL_SRCCOLORKEY set, only copy the pixels matching the * source colour key. * * RGBA->RGBA: * GAL_SRCALPHA set: * alpha-blend (using the source alpha channel) the RGB values; * leave destination alpha untouched. [Note: is this correct?] * GAL_SRCCOLORKEY ignored. * GAL_SRCALPHA not set: * copy all of RGBA to the destination. * if GAL_SRCCOLORKEY set, only copy the pixels matching the * RGB values of the source colour key, ignoring alpha in the * comparison. * * RGB->RGB: * GAL_SRCALPHA set: * alpha-blend (using the source per-surface alpha value). * GAL_SRCALPHA not set: * copy RGB. * both: * if GAL_SRCCOLORKEY set, only copy the pixels matching the * source colour key. * * If either of the surfaces were in video memory, and the blit returns -2, * the video memory was lost, so it should be reloaded with artwork and * re-blitted: while ( GAL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { while ( GAL_LockSurface(image) < 0 ) Sleep(10); -- Write image pixels to image->pixels -- GAL_UnlockSurface(image); } * This happens under DirectX 5.0 when the system switches away from your * fullscreen application. The lock will also fail until you have access * to the video memory again. *//* You should call GAL_BlitSurface() unless you know exactly how GAL blitting works internally and how to use the other blit functions.*/#define GAL_BlitSurface GAL_UpperBlit/* This is the public blit function, GAL_BlitSurface(), and it performs rectangle validation and clipping before passing it to GAL_LowerBlit()*/extern int GAL_UpperBlit (GAL_Surface *src, GAL_Rect *srcrect, GAL_Surface *dst, GAL_Rect *dstrect);/* This is a semi-private blit function and it performs low-level surface blitting only.*/extern int GAL_LowerBlit (GAL_Surface *src, GAL_Rect *srcrect, GAL_Surface *dst, GAL_Rect *dstrect);/* * This function performs a fast fill of the given rectangle with 'color' * The given rectangle is clipped to the destination surface clip area * and the final fill rectangle is saved in the passed in pointer. * If 'dstrect' is NULL, the whole surface will be filled with 'color' * The color should be a pixel of the format used by the surface, and * can be generated by the GAL_MapRGB() function. * This function returns 0 on success, or -1 on error. */extern int GAL_FillRect (GAL_Surface *dst, const GAL_Rect *dstrect, Uint32 color);/* * This function returns the size of pad-aligned box bitmap. */extern Uint32 GAL_GetBoxSize (GAL_Surface *src, Uint32 w, Uint32 h, Uint32* pitch_p);/* * This function copies pixels in a rect from the surface to a box. * You can calculate the box size like: * * size = GAL_GetBoxSize (src, &rect, NULL); * */extern int GAL_GetBox (GAL_Surface *src, const GAL_Rect* srcrect, BITMAP* box);/* * This function put pixels in a box to the rect on the surface. * * Note that the size of box should be equal to: * * size = GAL_GetBoxSize (src, &rect, NULL); * */extern int GAL_PutBox (GAL_Surface *dst, const GAL_Rect* dstrect, BITMAP* box);/* * This function takes a surface and copies it to a new surface of the * pixel format and colors of the video framebuffer, suitable for fast * blitting onto the display surface. It calls GAL_ConvertSurface() * * If you want to take advantage of hardware colorkey or alpha blit * acceleration, you should set the colorkey and alpha value before * calling this function. * * If the conversion fails or runs out of memory, it returns NULL */extern GAL_Surface * GAL_DisplayFormat (GAL_Surface *surface);/* * This function takes a surface and copies it to a new surface of the * pixel format and colors of the video framebuffer (if possible), * suitable for fast alpha blitting onto the display surface. * The new surface will always have an alpha channel. * * If you want to take advantage of hardware colorkey or alpha blit * acceleration, you should set the colorkey and alpha value before * calling this function. * * If the conversion fails or runs out of memory, it returns NULL */extern GAL_Surface * GAL_DisplayFormatAlpha (GAL_Surface *surface);/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//* YUV video surface overlay functions *//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//* This function creates a video output overlay Calling the returned surface an overlay is something of a misnomer because the contents of the display surface underneath the area where the overlay is shown is undefined - it may be overwritten with the converted YUV data.*/extern GAL_Overlay *GAL_CreateYUVOverlay (int width, int height, Uint32 format, GAL_Surface *display);#if 0/* Lock an overlay for direct access, and unlock it when you are done */extern int GAL_LockYUVOverlay (GAL_Overlay *overlay);extern void GAL_UnlockYUVOverlay (GAL_Overlay *overlay);/* Free a video overlay */extern void GAL_FreeYUVOverlay (GAL_Overlay *overlay);#endif/* Blit a video overlay to the display surface. The contents of the video surface underneath the blit destination are not defined. The width and height of the destination rectangle may be different from that of the overlay, but currently only 2x scaling is supported.*/extern int GAL_DisplayYUVOverlay (GAL_Overlay *overlay, GAL_Rect *dstrect);/* Not in public API at the moment - do not use! */extern int GAL_SoftStretch (GAL_Surface *src, GAL_Rect *srcrect, GAL_Surface *dst, GAL_Rect *dstrect);extern GAL_Surface* __gal_screen;#define WIDTHOFPHYGC (__gal_screen->w)#define HEIGHTOFPHYGC (__gal_screen->h)#define BYTESPERPHYPIXEL (__gal_screen->format->BytesPerPixel)#define BITSPERPHYPIXEL (__gal_screen->format->BitsPerPixel)#define GAL_BytesPerPixel(surface) (surface->format->BytesPerPixel)#define GAL_BitsPerPixel(surface) (surface->format->BitsPerPixel)#define GAL_Width(surface) (surface->w)#define GAL_Height(surface) (surface->h)extern int InitGAL (void);#define TerminateGAL GAL_VideoQuit#ifdef __cplusplus}#endif /* __cplusplus */#endif /* GUI_NEWGAL_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -