mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 12:58:08 +01:00
bug fixes, performance enhancement for image rendering
This commit is contained in:
@@ -21,8 +21,10 @@ Changes since version 0.53.0:
|
|||||||
- added high-quality filtered rescaling (smoothed rescaling) to wrlib/wmsetbg
|
- added high-quality filtered rescaling (smoothed rescaling) to wrlib/wmsetbg
|
||||||
- added SmoothWorkspaceBack
|
- added SmoothWorkspaceBack
|
||||||
- fixed crash bug in Paths section of WPrefs
|
- fixed crash bug in Paths section of WPrefs
|
||||||
|
- optimized image rendering for 15/16 bpp
|
||||||
- user menus' paths were changed. See NEWS.
|
- user menus' paths were changed. See NEWS.
|
||||||
|
|
||||||
|
|
||||||
Changes since version 0.52.0:
|
Changes since version 0.52.0:
|
||||||
.............................
|
.............................
|
||||||
|
|
||||||
|
|||||||
2
TODO
2
TODO
@@ -8,9 +8,7 @@ Do ASAP:
|
|||||||
- blink border of clients with UrgencyHint set between red and black
|
- blink border of clients with UrgencyHint set between red and black
|
||||||
- finish session stuff
|
- finish session stuff
|
||||||
- add multiline support for balloons
|
- add multiline support for balloons
|
||||||
- move/add balloon to WINGs
|
|
||||||
- finish XStandardColormap stuff in wrlib
|
- finish XStandardColormap stuff in wrlib
|
||||||
- finish menu editor/other stuff in wprefs
|
|
||||||
|
|
||||||
Need to do:
|
Need to do:
|
||||||
===========
|
===========
|
||||||
|
|||||||
@@ -188,6 +188,12 @@ W_BalloonHandleLeaveView(WMView *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* botar balao perto do cursor
|
||||||
|
* so mapear balao se o mouse ficar parado pelo delay
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
showBalloon(void *data)
|
showBalloon(void *data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1180,6 +1180,7 @@ handleTextFieldActionEvents(XEvent *event, void *data)
|
|||||||
if (tPtr->flags.pointerGrabbed) {
|
if (tPtr->flags.pointerGrabbed) {
|
||||||
tPtr->flags.pointerGrabbed = 0;
|
tPtr->flags.pointerGrabbed = 0;
|
||||||
XUngrabPointer(WMScreenDisplay(W_VIEW(tPtr)->screen), CurrentTime);
|
XUngrabPointer(WMScreenDisplay(W_VIEW(tPtr)->screen), CurrentTime);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
move = 1;
|
move = 1;
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ createPanel(Panel *p)
|
|||||||
WMMoveWidget(panel->sizeF, 20, 10);
|
WMMoveWidget(panel->sizeF, 20, 10);
|
||||||
WMSetFrameTitle(panel->sizeF, _("Size Display"));
|
WMSetFrameTitle(panel->sizeF, _("Size Display"));
|
||||||
|
|
||||||
|
WMSetBalloonTextForView(WMWidgetView(panel->posiF),
|
||||||
|
_("The position or style of the window size\n"
|
||||||
|
"display that's shown when a window is resized."));
|
||||||
|
|
||||||
panel->sizeP = WMCreatePopUpButton(panel->sizeF);
|
panel->sizeP = WMCreatePopUpButton(panel->sizeF);
|
||||||
WMResizeWidget(panel->sizeP, 180, 20);
|
WMResizeWidget(panel->sizeP, 180, 20);
|
||||||
WMMoveWidget(panel->sizeP, 32, 24);
|
WMMoveWidget(panel->sizeP, 32, 24);
|
||||||
@@ -174,6 +178,10 @@ createPanel(Panel *p)
|
|||||||
WMMoveWidget(panel->posiF, 20, 75);
|
WMMoveWidget(panel->posiF, 20, 75);
|
||||||
WMSetFrameTitle(panel->posiF, _("Position Display"));
|
WMSetFrameTitle(panel->posiF, _("Position Display"));
|
||||||
|
|
||||||
|
WMSetBalloonTextForView(WMWidgetView(panel->posiF),
|
||||||
|
_("The position or style of the window position\n"
|
||||||
|
"display that's shown when a window is moved."));
|
||||||
|
|
||||||
panel->posiP = WMCreatePopUpButton(panel->posiF);
|
panel->posiP = WMCreatePopUpButton(panel->posiF);
|
||||||
WMResizeWidget(panel->posiP, 180, 20);
|
WMResizeWidget(panel->posiP, 180, 20);
|
||||||
WMMoveWidget(panel->posiP, 32, 24);
|
WMMoveWidget(panel->posiP, 32, 24);
|
||||||
|
|||||||
@@ -862,7 +862,7 @@ handleLogoPush(XEvent *event, void *data)
|
|||||||
|
|
||||||
|
|
||||||
clicks++;
|
clicks++;
|
||||||
if (!panel->timer && !broken && clicks > 2) {
|
if (!panel->timer && !broken && clicks > 0) {
|
||||||
char *file;
|
char *file;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ static void paintButton(WCoreWindow *button, WTexture *texture,
|
|||||||
|
|
||||||
static void updateTitlebar(WFrameWindow *fwin);
|
static void updateTitlebar(WFrameWindow *fwin);
|
||||||
|
|
||||||
|
static void remakeTexture(WFrameWindow *fwin, int state, int newWidth);
|
||||||
|
|
||||||
|
static void updateTexture(WFrameWindow *fwin);
|
||||||
|
|
||||||
|
|
||||||
WFrameWindow*
|
WFrameWindow*
|
||||||
wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
|
wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
|
||||||
@@ -138,7 +142,9 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags)
|
|||||||
if (flags & WFF_TITLEBAR) {
|
if (flags & WFF_TITLEBAR) {
|
||||||
fwin->top_width = theight;
|
fwin->top_width = theight;
|
||||||
|
|
||||||
fwin->flags.need_texture_remake = 1;
|
fwin->flags.need_texture1_remake = 1;
|
||||||
|
fwin->flags.need_texture2_remake = 1;
|
||||||
|
fwin->flags.need_texture3_remake = 1;
|
||||||
|
|
||||||
if (wPreferences.new_style) {
|
if (wPreferences.new_style) {
|
||||||
if (fwin->left_button) {
|
if (fwin->left_button) {
|
||||||
@@ -245,7 +251,9 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags)
|
|||||||
|
|
||||||
XMapRaised(dpy, fwin->titlebar->window);
|
XMapRaised(dpy, fwin->titlebar->window);
|
||||||
|
|
||||||
fwin->flags.need_texture_remake = 1;
|
fwin->flags.need_texture1_remake = 1;
|
||||||
|
fwin->flags.need_texture2_remake = 1;
|
||||||
|
fwin->flags.need_texture3_remake = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkTitleSize(fwin);
|
checkTitleSize(fwin);
|
||||||
@@ -272,7 +280,9 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags)
|
|||||||
XMapWindow(dpy, fwin->resizebar->window);
|
XMapWindow(dpy, fwin->resizebar->window);
|
||||||
XLowerWindow(dpy, fwin->resizebar->window);
|
XLowerWindow(dpy, fwin->resizebar->window);
|
||||||
|
|
||||||
fwin->flags.need_texture_remake = 1;
|
fwin->flags.need_texture1_remake = 1;
|
||||||
|
fwin->flags.need_texture2_remake = 1;
|
||||||
|
fwin->flags.need_texture3_remake = 1;
|
||||||
} else {
|
} else {
|
||||||
if (height+fwin->top_width+fwin->bottom_width != fwin->core->height) {
|
if (height+fwin->top_width+fwin->bottom_width != fwin->core->height) {
|
||||||
wCoreConfigure(fwin->resizebar, 0, height + fwin->top_width,
|
wCoreConfigure(fwin->resizebar, 0, height + fwin->top_width,
|
||||||
@@ -405,8 +415,11 @@ updateTitlebar(WFrameWindow *fwin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wPreferences.new_style || fwin->titlebar->width!=w)
|
if (wPreferences.new_style || fwin->titlebar->width!=w) {
|
||||||
fwin->flags.need_texture_remake = 1;
|
fwin->flags.need_texture1_remake = 1;
|
||||||
|
fwin->flags.need_texture2_remake = 1;
|
||||||
|
fwin->flags.need_texture3_remake = 1;
|
||||||
|
}
|
||||||
|
|
||||||
wCoreConfigure(fwin->titlebar, x, 0, w, theight);
|
wCoreConfigure(fwin->titlebar, x, 0, w, theight);
|
||||||
}
|
}
|
||||||
@@ -646,12 +659,13 @@ updateTexture(WFrameWindow *fwin)
|
|||||||
handleButtonExpose(&fwin->right_button->descriptor, NULL);
|
handleButtonExpose(&fwin->right_button->descriptor, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
XFlush(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remakeTexture(WFrameWindow *fwin, int state)
|
remakeTexture(WFrameWindow *fwin, int state, int newWidth)
|
||||||
{
|
{
|
||||||
Pixmap pmap, lpmap, rpmap;
|
Pixmap pmap, lpmap, rpmap;
|
||||||
|
|
||||||
@@ -672,7 +686,7 @@ remakeTexture(WFrameWindow *fwin, int state)
|
|||||||
right = fwin->right_button && !fwin->flags.hide_right_button
|
right = fwin->right_button && !fwin->flags.hide_right_button
|
||||||
&& !fwin->flags.rbutton_dont_fit;
|
&& !fwin->flags.rbutton_dont_fit;
|
||||||
|
|
||||||
width = fwin->core->width+1;
|
width = newWidth+1;
|
||||||
|
|
||||||
renderTexture(fwin->screen_ptr, fwin->title_texture[state],
|
renderTexture(fwin->screen_ptr, fwin->title_texture[state],
|
||||||
width, fwin->titlebar->height,
|
width, fwin->titlebar->height,
|
||||||
@@ -687,7 +701,7 @@ remakeTexture(WFrameWindow *fwin, int state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fwin->resizebar_texture && fwin->resizebar_texture[0]
|
if (fwin->resizebar_texture && fwin->resizebar_texture[0]
|
||||||
&& fwin->resizebar && state == 0) {
|
&& fwin->resizebar && state == fwin->flags.state) {
|
||||||
|
|
||||||
FREE_PIXMAP(fwin->resizebar_back[0]);
|
FREE_PIXMAP(fwin->resizebar_back[0]);
|
||||||
|
|
||||||
@@ -695,8 +709,7 @@ remakeTexture(WFrameWindow *fwin, int state)
|
|||||||
|
|
||||||
renderResizebarTexture(fwin->screen_ptr,
|
renderResizebarTexture(fwin->screen_ptr,
|
||||||
fwin->resizebar_texture[0],
|
fwin->resizebar_texture[0],
|
||||||
fwin->resizebar->width,
|
newWidth, fwin->resizebar->height,
|
||||||
fwin->resizebar->height,
|
|
||||||
fwin->resizebar_corner_width,
|
fwin->resizebar_corner_width,
|
||||||
&pmap);
|
&pmap);
|
||||||
|
|
||||||
@@ -722,25 +735,36 @@ wFrameWindowPaint(WFrameWindow *fwin)
|
|||||||
if (fwin->flags.is_client_window_frame)
|
if (fwin->flags.is_client_window_frame)
|
||||||
fwin->flags.justification = wPreferences.title_justification;
|
fwin->flags.justification = wPreferences.title_justification;
|
||||||
|
|
||||||
if (fwin->flags.need_texture_remake) {
|
if (fwin->flags.need_texture1_remake || fwin->flags.need_texture2_remake
|
||||||
int i;
|
|| fwin->flags.need_texture3_remake) {
|
||||||
|
|
||||||
fwin->flags.need_texture_remake = 0;
|
|
||||||
fwin->flags.need_texture_change = 0;
|
|
||||||
|
|
||||||
if (fwin->flags.single_texture) {
|
if (fwin->flags.single_texture) {
|
||||||
remakeTexture(fwin, 0);
|
|
||||||
updateTexture(fwin);
|
|
||||||
} else {
|
|
||||||
/* first render the texture for the current state... */
|
|
||||||
remakeTexture(fwin, fwin->flags.state);
|
|
||||||
/* ... and paint it */
|
|
||||||
updateTexture(fwin);
|
|
||||||
|
|
||||||
for (i=0; i < 3; i++) {
|
fwin->flags.need_texture_change = 1;
|
||||||
if (i!=fwin->flags.state)
|
|
||||||
remakeTexture(fwin, i);
|
fwin->flags.need_texture1_remake = 0;
|
||||||
}
|
fwin->flags.need_texture2_remake = 0;
|
||||||
|
fwin->flags.need_texture3_remake = 0;
|
||||||
|
|
||||||
|
remakeTexture(fwin, 0, fwin->core->width);
|
||||||
|
|
||||||
|
} else if (fwin->flags.state==0 && fwin->flags.need_texture1_remake) {
|
||||||
|
|
||||||
|
fwin->flags.need_texture_change = 1;
|
||||||
|
fwin->flags.need_texture1_remake = 0;
|
||||||
|
remakeTexture(fwin, fwin->flags.state, fwin->core->width);
|
||||||
|
|
||||||
|
} else if (fwin->flags.state==1 && fwin->flags.need_texture2_remake) {
|
||||||
|
|
||||||
|
fwin->flags.need_texture_change = 1;
|
||||||
|
fwin->flags.need_texture2_remake = 0;
|
||||||
|
remakeTexture(fwin, fwin->flags.state, fwin->core->width);
|
||||||
|
|
||||||
|
} else if (fwin->flags.state==2 && fwin->flags.need_texture3_remake) {
|
||||||
|
|
||||||
|
fwin->flags.need_texture_change = 1;
|
||||||
|
fwin->flags.need_texture3_remake = 0;
|
||||||
|
remakeTexture(fwin, fwin->flags.state, fwin->core->width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,7 +877,7 @@ wFrameWindowPaint(WFrameWindow *fwin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TITLE_TEXT_SHADOW
|
#ifdef TITLE_TEXT_SHADOW
|
||||||
if(wPreferences.title_shadow){
|
if(wPreferences.title_shadow) {
|
||||||
int shadowx,shadowy;
|
int shadowx,shadowy;
|
||||||
XSetForeground(dpy, *fwin->title_gc,
|
XSetForeground(dpy, *fwin->title_gc,
|
||||||
fwin->title_pixel[fwin->flags.state+3]);
|
fwin->title_pixel[fwin->flags.state+3]);
|
||||||
@@ -904,7 +928,6 @@ reconfigure(WFrameWindow *fwin, int x, int y, int width, int height,
|
|||||||
height - fwin->resizebar->height);
|
height - fwin->resizebar->height);
|
||||||
*/
|
*/
|
||||||
if (fwin->core->width != width) {
|
if (fwin->core->width != width) {
|
||||||
fwin->flags.need_texture_remake = 1;
|
|
||||||
resizedHorizontally = 1;
|
resizedHorizontally = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -973,12 +996,14 @@ reconfigure(WFrameWindow *fwin, int x, int y, int width, int height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wFrameWindowConfigure(WFrameWindow *fwin, int x, int y, int width, int height)
|
wFrameWindowConfigure(WFrameWindow *fwin, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
reconfigure(fwin, x, y, width, height, False);
|
reconfigure(fwin, x, y, width, height, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wFrameWindowResize(WFrameWindow *fwin, int width, int height)
|
wFrameWindowResize(WFrameWindow *fwin, int width, int height)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,7 +98,11 @@ typedef struct WFrameWindow {
|
|||||||
unsigned int resizebar:1;
|
unsigned int resizebar:1;
|
||||||
unsigned int left_button:1;
|
unsigned int left_button:1;
|
||||||
unsigned int right_button:1;
|
unsigned int right_button:1;
|
||||||
unsigned int need_texture_remake:1;
|
|
||||||
|
unsigned int need_texture1_remake:1;
|
||||||
|
unsigned int need_texture2_remake:1;
|
||||||
|
unsigned int need_texture3_remake:1;
|
||||||
|
|
||||||
unsigned int single_texture:1;
|
unsigned int single_texture:1;
|
||||||
|
|
||||||
unsigned int hide_left_button:1;
|
unsigned int hide_left_button:1;
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ appearanceObserver(void *self, WMNotification *notif)
|
|||||||
wMenuRealize(menu);
|
wMenuRealize(menu);
|
||||||
}
|
}
|
||||||
if (flags & WTextureSettings) {
|
if (flags & WTextureSettings) {
|
||||||
menu->frame->flags.need_texture_remake = 1;
|
menu->frame->flags.need_texture1_remake = 1;
|
||||||
}
|
}
|
||||||
if (flags & (WColorSettings|WTextureSettings))
|
if (flags & (WColorSettings|WTextureSettings))
|
||||||
wFrameWindowPaint(menu->frame);
|
wFrameWindowPaint(menu->frame);
|
||||||
|
|||||||
@@ -714,7 +714,10 @@ wScreenInit(int screen_number)
|
|||||||
|
|
||||||
/* screen descriptor for raster graphic library */
|
/* screen descriptor for raster graphic library */
|
||||||
rattr.flags = RC_RenderMode | RC_ColorsPerChannel;
|
rattr.flags = RC_RenderMode | RC_ColorsPerChannel;
|
||||||
rattr.render_mode = wPreferences.no_dithering?RM_MATCH:RM_DITHER;
|
rattr.render_mode = wPreferences.no_dithering
|
||||||
|
? RBestMatchRendering
|
||||||
|
: RDitheredRendering;
|
||||||
|
|
||||||
rattr.colors_per_channel = wPreferences.cmap_size;
|
rattr.colors_per_channel = wPreferences.cmap_size;
|
||||||
if (rattr.colors_per_channel<2)
|
if (rattr.colors_per_channel<2)
|
||||||
rattr.colors_per_channel = 2;
|
rattr.colors_per_channel = 2;
|
||||||
|
|||||||
@@ -363,7 +363,7 @@
|
|||||||
#define MENU_SELECT_DELAY 200
|
#define MENU_SELECT_DELAY 200
|
||||||
|
|
||||||
/* delay for jumpback of scrolled menus */
|
/* delay for jumpback of scrolled menus */
|
||||||
#define MENU_JUMP_BACK_DELAY 300
|
#define MENU_JUMP_BACK_DELAY 400
|
||||||
|
|
||||||
/* *** animation speed constants *** */
|
/* *** animation speed constants *** */
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,9 @@ appearanceObserver(void *self, WMNotification *notif)
|
|||||||
wWindowConfigureBorders(wwin);
|
wWindowConfigureBorders(wwin);
|
||||||
}
|
}
|
||||||
if (flags & WTextureSettings) {
|
if (flags & WTextureSettings) {
|
||||||
wwin->frame->flags.need_texture_remake = 1;
|
wwin->frame->flags.need_texture1_remake = 1;
|
||||||
|
wwin->frame->flags.need_texture2_remake = 1;
|
||||||
|
wwin->frame->flags.need_texture3_remake = 1;
|
||||||
}
|
}
|
||||||
if (flags & (WTextureSettings | WColorSettings)) {
|
if (flags & (WTextureSettings | WColorSettings)) {
|
||||||
if (wwin->frame->titlebar)
|
if (wwin->frame->titlebar)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ static Bool bestContext(Display *dpy, int screen_number, RContext *context);
|
|||||||
|
|
||||||
static RContextAttributes DEFAULT_CONTEXT_ATTRIBS = {
|
static RContextAttributes DEFAULT_CONTEXT_ATTRIBS = {
|
||||||
RC_UseSharedMemory|RC_RenderMode|RC_ColorsPerChannel, /* flags */
|
RC_UseSharedMemory|RC_RenderMode|RC_ColorsPerChannel, /* flags */
|
||||||
RM_DITHER, /* render_mode */
|
RDitheredRendering, /* render_mode */
|
||||||
4, /* colors_per_channel */
|
4, /* colors_per_channel */
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -204,7 +204,7 @@ allocateGrayScale(RContext *ctx)
|
|||||||
|
|
||||||
if (ncolors>=256 && ctx->vclass==StaticGray) {
|
if (ncolors>=256 && ctx->vclass==StaticGray) {
|
||||||
/* don't need dithering for 256 levels of gray in StaticGray visual */
|
/* don't need dithering for 256 levels of gray in StaticGray visual */
|
||||||
ctx->attribs->render_mode = RM_MATCH;
|
ctx->attribs->render_mode = RBestMatchRendering;
|
||||||
}
|
}
|
||||||
|
|
||||||
colors = malloc(sizeof(XColor)*ncolors);
|
colors = malloc(sizeof(XColor)*ncolors);
|
||||||
@@ -491,7 +491,7 @@ RCreateContext(Display *dpy, int screen_number, RContextAttributes *attribs)
|
|||||||
context->blue_offset = count_offset(context->visual->blue_mask);
|
context->blue_offset = count_offset(context->visual->blue_mask);
|
||||||
/* disable dithering on 24 bits visuals */
|
/* disable dithering on 24 bits visuals */
|
||||||
if (context->depth >= 24)
|
if (context->depth >= 24)
|
||||||
context->attribs->render_mode = RM_MATCH;
|
context->attribs->render_mode = RBestMatchRendering;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check avaiability of MIT-SHM */
|
/* check avaiability of MIT-SHM */
|
||||||
|
|||||||
197
wrlib/convert.c
197
wrlib/convert.c
@@ -93,6 +93,147 @@ computeTable(unsigned short mask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static RXImage*
|
||||||
|
image2TrueColorD16(RContext *ctx, RImage *image)
|
||||||
|
{
|
||||||
|
RXImage *ximg;
|
||||||
|
register int x, y, r, g, b;
|
||||||
|
unsigned char *red, *grn, *blu;
|
||||||
|
unsigned short rmask, gmask, bmask;
|
||||||
|
unsigned short roffs, goffs, boffs;
|
||||||
|
unsigned short *rtable, *gtable, *btable;
|
||||||
|
int ofs;
|
||||||
|
|
||||||
|
ximg = RCreateXImage(ctx, ctx->depth, image->width, image->height);
|
||||||
|
if (!ximg) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
red = image->data[0];
|
||||||
|
grn = image->data[1];
|
||||||
|
blu = image->data[2];
|
||||||
|
|
||||||
|
roffs = ctx->red_offset;
|
||||||
|
goffs = ctx->green_offset;
|
||||||
|
boffs = ctx->blue_offset;
|
||||||
|
|
||||||
|
rmask = ctx->visual->red_mask >> roffs;
|
||||||
|
gmask = ctx->visual->green_mask >> goffs;
|
||||||
|
bmask = ctx->visual->blue_mask >> boffs;
|
||||||
|
|
||||||
|
rtable = computeTable(rmask);
|
||||||
|
gtable = computeTable(gmask);
|
||||||
|
btable = computeTable(bmask);
|
||||||
|
|
||||||
|
if (rtable==NULL || gtable==NULL || btable==NULL) {
|
||||||
|
RErrorCode = RERR_NOMEMORY;
|
||||||
|
RDestroyXImage(ctx, ximg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
/* dither */
|
||||||
|
short *rerr, *gerr, *berr;
|
||||||
|
short *nrerr, *ngerr, *nberr;
|
||||||
|
short *terr;
|
||||||
|
unsigned short *dataP;
|
||||||
|
int line_offset;
|
||||||
|
int rer, ger, ber;
|
||||||
|
const int dr=0xff/rmask;
|
||||||
|
const int dg=0xff/gmask;
|
||||||
|
const int db=0xff/bmask;
|
||||||
|
|
||||||
|
rerr = (short*)alloca((image->width+2)*sizeof(short));
|
||||||
|
gerr = (short*)alloca((image->width+2)*sizeof(short));
|
||||||
|
berr = (short*)alloca((image->width+2)*sizeof(short));
|
||||||
|
nrerr = (short*)alloca((image->width+2)*sizeof(short));
|
||||||
|
ngerr = (short*)alloca((image->width+2)*sizeof(short));
|
||||||
|
nberr = (short*)alloca((image->width+2)*sizeof(short));
|
||||||
|
if (!rerr || !gerr || !berr || !nrerr || !ngerr || !nberr) {
|
||||||
|
RErrorCode = RERR_NOMEMORY;
|
||||||
|
RDestroyXImage(ctx, ximg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
for (x=0; x<image->width; x++) {
|
||||||
|
rerr[x] = red[x];
|
||||||
|
gerr[x] = grn[x];
|
||||||
|
berr[x] = blu[x];
|
||||||
|
}
|
||||||
|
rerr[x] = gerr[x] = berr[x] = 0;
|
||||||
|
|
||||||
|
dataP = (unsigned short*)ximg->image->data;
|
||||||
|
line_offset = ximg->image->bytes_per_line - image->width * 2;
|
||||||
|
|
||||||
|
/* convert and dither the image to XImage */
|
||||||
|
for (y=0, ofs=0; y<image->height; y++) {
|
||||||
|
if (y<image->height-1) {
|
||||||
|
int x1;
|
||||||
|
for (x=0, x1=ofs+image->width; x<image->width; x++, x1++) {
|
||||||
|
nrerr[x] = red[x1];
|
||||||
|
ngerr[x] = grn[x1];
|
||||||
|
nberr[x] = blu[x1];
|
||||||
|
}
|
||||||
|
/* last column */
|
||||||
|
x1--;
|
||||||
|
nrerr[x] = red[x1];
|
||||||
|
ngerr[x] = grn[x1];
|
||||||
|
nberr[x] = blu[x1];
|
||||||
|
}
|
||||||
|
for (x=0; x<image->width; x++) {
|
||||||
|
/* reduce pixel */
|
||||||
|
if (rerr[x]>0xff) rerr[x]=0xff; else if (rerr[x]<0) rerr[x]=0;
|
||||||
|
if (gerr[x]>0xff) gerr[x]=0xff; else if (gerr[x]<0) gerr[x]=0;
|
||||||
|
if (berr[x]>0xff) berr[x]=0xff; else if (berr[x]<0) berr[x]=0;
|
||||||
|
|
||||||
|
r = rtable[rerr[x]];
|
||||||
|
g = gtable[gerr[x]];
|
||||||
|
b = btable[berr[x]];
|
||||||
|
|
||||||
|
*(dataP++) = (r<<roffs) | (g<<goffs) | (b<<boffs);
|
||||||
|
|
||||||
|
/* calc error */
|
||||||
|
rer = rerr[x] - r*dr;
|
||||||
|
ger = gerr[x] - g*dg;
|
||||||
|
ber = berr[x] - b*db;
|
||||||
|
|
||||||
|
/* distribute error */
|
||||||
|
r = (rer*3)/8;
|
||||||
|
g = (ger*3)/8;
|
||||||
|
b = (ber*3)/8;
|
||||||
|
/* x+1, y */
|
||||||
|
rerr[x+1]+=r;
|
||||||
|
gerr[x+1]+=g;
|
||||||
|
berr[x+1]+=b;
|
||||||
|
/* x, y+1 */
|
||||||
|
nrerr[x]+=r;
|
||||||
|
ngerr[x]+=g;
|
||||||
|
nberr[x]+=b;
|
||||||
|
/* x+1, y+1 */
|
||||||
|
nrerr[x+1]+=rer-2*r;
|
||||||
|
ngerr[x+1]+=ger-2*g;
|
||||||
|
nberr[x+1]+=ber-2*b;
|
||||||
|
}
|
||||||
|
ofs += image->width;
|
||||||
|
(char*)dataP += line_offset;
|
||||||
|
/* skip to next line */
|
||||||
|
terr = rerr;
|
||||||
|
rerr = nrerr;
|
||||||
|
nrerr = terr;
|
||||||
|
|
||||||
|
terr = gerr;
|
||||||
|
gerr = ngerr;
|
||||||
|
ngerr = terr;
|
||||||
|
|
||||||
|
terr = berr;
|
||||||
|
berr = nberr;
|
||||||
|
nberr = terr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ximg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static RXImage*
|
static RXImage*
|
||||||
image2TrueColor(RContext *ctx, RImage *image)
|
image2TrueColor(RContext *ctx, RImage *image)
|
||||||
{
|
{
|
||||||
@@ -151,7 +292,7 @@ image2TrueColor(RContext *ctx, RImage *image)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->attribs->render_mode==RM_MATCH) {
|
if (ctx->attribs->render_mode==RBestMatchRendering) {
|
||||||
/* fake match */
|
/* fake match */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
puts("true color match");
|
puts("true color match");
|
||||||
@@ -264,6 +405,8 @@ image2TrueColor(RContext *ctx, RImage *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static RXImage*
|
static RXImage*
|
||||||
image2PseudoColor(RContext *ctx, RImage *image)
|
image2PseudoColor(RContext *ctx, RImage *image)
|
||||||
{
|
{
|
||||||
@@ -303,7 +446,7 @@ image2PseudoColor(RContext *ctx, RImage *image)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->attribs->render_mode == RM_MATCH) {
|
if (ctx->attribs->render_mode == RBestMatchRendering) {
|
||||||
/* fake match */
|
/* fake match */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("pseudo color match with %d colors per channel\n", cpc);
|
printf("pseudo color match with %d colors per channel\n", cpc);
|
||||||
@@ -477,7 +620,7 @@ image2GrayScale(RContext *ctx, RImage *image)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->attribs->render_mode == RM_MATCH) {
|
if (ctx->attribs->render_mode == RBestMatchRendering) {
|
||||||
/* fake match */
|
/* fake match */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("grayscale match with %d colors per channel\n", cpc);
|
printf("grayscale match with %d colors per channel\n", cpc);
|
||||||
@@ -594,12 +737,18 @@ RConvertImage(RContext *context, RImage *image, Pixmap *pixmap)
|
|||||||
assert(pixmap!=NULL);
|
assert(pixmap!=NULL);
|
||||||
|
|
||||||
/* clear error message */
|
/* clear error message */
|
||||||
if (context->vclass == TrueColor)
|
if (context->vclass == TrueColor) {
|
||||||
ximg = image2TrueColor(context, image);
|
|
||||||
else if (context->vclass == PseudoColor || context->vclass == StaticColor)
|
if (context->attribs->render_mode == RDitheredRendering
|
||||||
ximg = image2PseudoColor(context, image);
|
&& (context->depth == 15 || context->depth == 16))
|
||||||
|
ximg = image2TrueColorD16(context, image);
|
||||||
|
else
|
||||||
|
ximg = image2TrueColor(context, image);
|
||||||
|
|
||||||
|
} else if (context->vclass == PseudoColor || context->vclass == StaticColor)
|
||||||
|
ximg = image2PseudoColor(context, image);
|
||||||
else if (context->vclass == GrayScale || context->vclass == StaticGray)
|
else if (context->vclass == GrayScale || context->vclass == StaticGray)
|
||||||
ximg = image2GrayScale(context, image);
|
ximg = image2GrayScale(context, image);
|
||||||
|
|
||||||
if (!ximg) {
|
if (!ximg) {
|
||||||
#ifdef C_ALLOCA
|
#ifdef C_ALLOCA
|
||||||
@@ -696,37 +845,6 @@ RConvertImageMask(RContext *context, RImage *image, Pixmap *pixmap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
RSmoothScaleBorderConvertImage(RContext *context, RImage *image,
|
|
||||||
int newWidth, int newHeight, int borderType,
|
|
||||||
Pixmap *pixmap)
|
|
||||||
{
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
RScaleBorderConvertImage(RContext *context, RImage *image,
|
|
||||||
int newWidth, int newHeight, int borderType,
|
|
||||||
Pixmap *pixmap)
|
|
||||||
{
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
RGetClosestXColor(RContext *context, RColor *color, XColor *retColor)
|
RGetClosestXColor(RContext *context, RColor *color, XColor *retColor)
|
||||||
{
|
{
|
||||||
@@ -801,3 +919,4 @@ RGetClosestXColor(RContext *context, RColor *color, XColor *retColor)
|
|||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
175
wrlib/scale.c
175
wrlib/scale.c
@@ -48,102 +48,101 @@
|
|||||||
*----------------------------------------------------------------------
|
*----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
RImage*
|
RImage*
|
||||||
RScaleImage(RImage *image, unsigned new_width, unsigned new_height)
|
RScaleImage(RImage *src, unsigned new_width, unsigned new_height)
|
||||||
{
|
{
|
||||||
int ox;
|
int ddy, ee;
|
||||||
int px, py;
|
int h2;
|
||||||
register int x, y, t;
|
int yd;
|
||||||
int dx, dy;
|
int xd, xs;
|
||||||
|
RImage *dst;
|
||||||
|
int e, xd2;
|
||||||
unsigned char *sr, *sg, *sb, *sa;
|
unsigned char *sr, *sg, *sb, *sa;
|
||||||
unsigned char *dr, *dg, *db, *da;
|
unsigned char *dr, *dg, *db, *da;
|
||||||
RImage *img;
|
int ys = 0;
|
||||||
|
|
||||||
assert(new_width >= 0 && new_height >= 0);
|
|
||||||
|
|
||||||
if (new_width == image->width && new_height == image->height)
|
|
||||||
return RCloneImage(image);
|
|
||||||
|
|
||||||
img = RCreateImage(new_width, new_height, image->data[3]!=NULL);
|
dst = RCreateImage(new_width, new_height, src->data[3]!=NULL);
|
||||||
|
|
||||||
if (!img)
|
ddy = src->height/2;
|
||||||
return NULL;
|
ee = (ddy/2) - dst->height;
|
||||||
|
h2 = new_height/2;
|
||||||
|
|
||||||
/* fixed point math idea taken from Imlib by
|
xd = dst->width;
|
||||||
* Carsten Haitzler (Rasterman) */
|
xs = src->width/2;
|
||||||
dx = (image->width<<16)/new_width;
|
e = (src->width/2)-xd;
|
||||||
dy = (image->height<<16)/new_height;
|
xd2 = xd/2;
|
||||||
|
|
||||||
py = 0;
|
sr = src->data[0];
|
||||||
|
sg = src->data[1];
|
||||||
|
sb = src->data[2];
|
||||||
|
sa = src->data[3];
|
||||||
|
|
||||||
dr = img->data[0];
|
dr = dst->data[0];
|
||||||
dg = img->data[1];
|
dg = dst->data[1];
|
||||||
db = img->data[2];
|
db = dst->data[2];
|
||||||
da = img->data[3];
|
da = dst->data[3];
|
||||||
|
|
||||||
if (image->data[3]!=NULL) {
|
if (sa == NULL) {
|
||||||
int ot;
|
for (yd = 0; yd < new_height; yd++) {
|
||||||
ot = -1;
|
int x;
|
||||||
for (y=0; y<new_height; y++) {
|
|
||||||
t = image->width*(py>>16);
|
|
||||||
|
|
||||||
sr = image->data[0]+t;
|
sr = src->data[0] + ys * src->width;
|
||||||
sg = image->data[1]+t;
|
sg = src->data[1] + ys * src->width;
|
||||||
sb = image->data[2]+t;
|
sb = src->data[2] + ys * src->width;
|
||||||
sa = image->data[3]+t;
|
|
||||||
|
|
||||||
ot = t;
|
for (x = 0; x < xd; x++) {
|
||||||
ox = 0;
|
*(dr++) = *sr;
|
||||||
px = 0;
|
*(dg++) = *sg;
|
||||||
for (x=0; x<new_width; x++) {
|
*(db++) = *sb;
|
||||||
px += dx;
|
|
||||||
|
|
||||||
|
while (e >= 0) {
|
||||||
|
sr++;
|
||||||
|
sg++;
|
||||||
|
sb++;
|
||||||
|
e -= xd2;
|
||||||
|
}
|
||||||
|
e += xs;
|
||||||
|
}
|
||||||
|
while (ee >= 0) {
|
||||||
|
ys++;
|
||||||
|
ee -= h2;
|
||||||
|
}
|
||||||
|
ee += ddy;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (yd = 0; yd < new_height; yd++) {
|
||||||
|
int x;
|
||||||
|
|
||||||
|
sr = src->data[0] + ys * src->width;
|
||||||
|
sg = src->data[1] + ys * src->width;
|
||||||
|
sb = src->data[2] + ys * src->width;
|
||||||
|
sa = src->data[3] + ys * src->width;
|
||||||
|
|
||||||
|
for (x = 0; x < xd; x++) {
|
||||||
*(dr++) = *sr;
|
*(dr++) = *sr;
|
||||||
*(dg++) = *sg;
|
*(dg++) = *sg;
|
||||||
*(db++) = *sb;
|
*(db++) = *sb;
|
||||||
*(da++) = *sa;
|
*(da++) = *sa;
|
||||||
|
|
||||||
t = (px - ox)>>16;
|
while (e >= 0) {
|
||||||
ox += t<<16;
|
sr++;
|
||||||
|
sg++;
|
||||||
sr += t;
|
sb++;
|
||||||
sg += t;
|
sa++;
|
||||||
sb += t;
|
e -= xd2;
|
||||||
sa += t;
|
}
|
||||||
|
e += xs;
|
||||||
}
|
}
|
||||||
py += dy;
|
while (ee >= 0) {
|
||||||
}
|
ys++;
|
||||||
} else {
|
ee -= h2;
|
||||||
int ot;
|
|
||||||
ot = -1;
|
|
||||||
for (y=0; y<new_height; y++) {
|
|
||||||
t = image->width*(py>>16);
|
|
||||||
|
|
||||||
sr = image->data[0]+t;
|
|
||||||
sg = image->data[1]+t;
|
|
||||||
sb = image->data[2]+t;
|
|
||||||
|
|
||||||
ot = t;
|
|
||||||
ox = 0;
|
|
||||||
px = 0;
|
|
||||||
for (x=0; x<new_width; x++) {
|
|
||||||
px += dx;
|
|
||||||
|
|
||||||
*(dr++) = *sr;
|
|
||||||
*(dg++) = *sg;
|
|
||||||
*(db++) = *sb;
|
|
||||||
|
|
||||||
t = (px-ox)>>16;
|
|
||||||
ox += t<<16;
|
|
||||||
|
|
||||||
sr += t;
|
|
||||||
sg += t;
|
|
||||||
sb += t;
|
|
||||||
}
|
}
|
||||||
py += dy;
|
ee += ddy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return img;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -159,7 +158,7 @@ RScaleImage(RImage *image, unsigned new_width, unsigned new_height)
|
|||||||
/*
|
/*
|
||||||
* filter function definitions
|
* filter function definitions
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
#define filter_support (1.0)
|
#define filter_support (1.0)
|
||||||
|
|
||||||
static double
|
static double
|
||||||
@@ -171,7 +170,7 @@ double t;
|
|||||||
if(t < 1.0) return((2.0 * t - 3.0) * t * t + 1.0);
|
if(t < 1.0) return((2.0 * t - 3.0) * t * t + 1.0);
|
||||||
return(0.0);
|
return(0.0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#define box_support (0.5)
|
#define box_support (0.5)
|
||||||
|
|
||||||
static double
|
static double
|
||||||
@@ -304,8 +303,8 @@ _wraster_change_filter(int type)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case RMitchellFilter:
|
case RMitchellFilter:
|
||||||
filterf = Mitchell_support;
|
filterf = Mitchell_filter;
|
||||||
fwidth = Mitchell_filter;
|
fwidth = Mitchell_support;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,7 +331,7 @@ CLIST *contrib; /* array of contribution lists */
|
|||||||
|
|
||||||
|
|
||||||
RImage*
|
RImage*
|
||||||
RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
RSmoothScaleImage(RImage *src, unsigned new_width, unsigned new_height)
|
||||||
{
|
{
|
||||||
RImage *tmp; /* intermediate image */
|
RImage *tmp; /* intermediate image */
|
||||||
double xscale, yscale; /* zoom scale factors */
|
double xscale, yscale; /* zoom scale factors */
|
||||||
@@ -345,19 +344,19 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
|||||||
unsigned char *rp, *gp, *bp;
|
unsigned char *rp, *gp, *bp;
|
||||||
unsigned char *rsp, *gsp, *bsp;
|
unsigned char *rsp, *gsp, *bsp;
|
||||||
|
|
||||||
dst = RCreateImage(newWidth, newHeight, False);
|
dst = RCreateImage(new_width, new_height, False);
|
||||||
|
|
||||||
/* create intermediate image to hold horizontal zoom */
|
/* create intermediate image to hold horizontal zoom */
|
||||||
tmp = RCreateImage(dst->width, src->height, False);
|
tmp = RCreateImage(dst->width, src->height, False);
|
||||||
xscale = (double)newWidth / (double)src->width;
|
xscale = (double)new_width / (double)src->width;
|
||||||
yscale = (double)newHeight / (double)src->height;
|
yscale = (double)new_height / (double)src->height;
|
||||||
|
|
||||||
/* pre-calculate filter contributions for a row */
|
/* pre-calculate filter contributions for a row */
|
||||||
contrib = (CLIST *)calloc(newWidth, sizeof(CLIST));
|
contrib = (CLIST *)calloc(new_width, sizeof(CLIST));
|
||||||
if (xscale < 1.0) {
|
if (xscale < 1.0) {
|
||||||
width = fwidth / xscale;
|
width = fwidth / xscale;
|
||||||
fscale = 1.0 / xscale;
|
fscale = 1.0 / xscale;
|
||||||
for (i = 0; i < newWidth; ++i) {
|
for (i = 0; i < new_width; ++i) {
|
||||||
contrib[i].n = 0;
|
contrib[i].n = 0;
|
||||||
contrib[i].p = (CONTRIB *)calloc((int)(width * 2 + 1),
|
contrib[i].p = (CONTRIB *)calloc((int)(width * 2 + 1),
|
||||||
sizeof(CONTRIB));
|
sizeof(CONTRIB));
|
||||||
@@ -380,7 +379,7 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(i = 0; i < newWidth; ++i) {
|
for(i = 0; i < new_width; ++i) {
|
||||||
contrib[i].n = 0;
|
contrib[i].n = 0;
|
||||||
contrib[i].p = (CONTRIB *)calloc((int) (fwidth * 2 + 1),
|
contrib[i].p = (CONTRIB *)calloc((int) (fwidth * 2 + 1),
|
||||||
sizeof(CONTRIB));
|
sizeof(CONTRIB));
|
||||||
@@ -490,7 +489,7 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
|||||||
gsp = malloc(tmp->height);
|
gsp = malloc(tmp->height);
|
||||||
bsp = malloc(tmp->height);
|
bsp = malloc(tmp->height);
|
||||||
|
|
||||||
for(k = 0; k < newWidth; ++k) {
|
for(k = 0; k < new_width; ++k) {
|
||||||
rp = dst->data[0] + k;
|
rp = dst->data[0] + k;
|
||||||
gp = dst->data[1] + k;
|
gp = dst->data[1] + k;
|
||||||
bp = dst->data[2] + k;
|
bp = dst->data[2] + k;
|
||||||
@@ -516,7 +515,7 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
|||||||
*d++ = *p;
|
*d++ = *p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i = 0; i < newHeight; ++i) {
|
for(i = 0; i < new_height; ++i) {
|
||||||
rweight = gweight = bweight = 0.0;
|
rweight = gweight = bweight = 0.0;
|
||||||
for(j = 0; j < contrib[i].n; ++j) {
|
for(j = 0; j < contrib[i].n; ++j) {
|
||||||
rweight += rsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;
|
rweight += rsp[contrib[i].p[j].pixel] * contrib[i].p[j].weight;
|
||||||
@@ -526,9 +525,9 @@ RSmoothScaleImage(RImage *src, int newWidth, int newHeight)
|
|||||||
*rp = CLAMP(rweight, 0, 255);
|
*rp = CLAMP(rweight, 0, 255);
|
||||||
*gp = CLAMP(gweight, 0, 255);
|
*gp = CLAMP(gweight, 0, 255);
|
||||||
*bp = CLAMP(bweight, 0, 255);
|
*bp = CLAMP(bweight, 0, 255);
|
||||||
rp += newWidth;
|
rp += new_width;
|
||||||
gp += newWidth;
|
gp += new_width;
|
||||||
bp += newWidth;
|
bp += new_width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(rsp);
|
free(rsp);
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
attr.flags = RC_RenderMode | RC_ColorsPerChannel;
|
attr.flags = RC_RenderMode | RC_ColorsPerChannel;
|
||||||
|
|
||||||
attr.render_mode = RM_DITHER;
|
attr.render_mode = RDitheredRendering;
|
||||||
attr.colors_per_channel = 4;
|
attr.colors_per_channel = 4;
|
||||||
|
|
||||||
if (visualID >= 0) {
|
if (visualID >= 0) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
RContextAttributes attr;
|
RContextAttributes attr;
|
||||||
RColor **colors = NULL;
|
RColor **colors = NULL;
|
||||||
int i, rmode = RM_DITHER, ncolors = 0, cpc = 4;
|
int i, rmode = RDitheredRendering, ncolors = 0, cpc = 4;
|
||||||
char **color_name;
|
char **color_name;
|
||||||
XColor color;
|
XColor color;
|
||||||
XSetWindowAttributes val;
|
XSetWindowAttributes val;
|
||||||
@@ -59,9 +59,9 @@ int main(int argc, char **argv)
|
|||||||
if (argc>1) {
|
if (argc>1) {
|
||||||
for (i=1; i<argc; i++) {
|
for (i=1; i<argc; i++) {
|
||||||
if (strcmp(argv[i], "-m")==0) {
|
if (strcmp(argv[i], "-m")==0) {
|
||||||
rmode = RM_MATCH;
|
rmode = RBestMatchRendering;
|
||||||
} else if (strcmp(argv[i], "-d")==0) {
|
} else if (strcmp(argv[i], "-d")==0) {
|
||||||
rmode = RM_DITHER;
|
rmode = RDitheredRendering;
|
||||||
} else if (strcmp(argv[i], "-c")==0) {
|
} else if (strcmp(argv[i], "-c")==0) {
|
||||||
i++;
|
i++;
|
||||||
if (i>=argc) {
|
if (i>=argc) {
|
||||||
@@ -161,11 +161,11 @@ int main(int argc, char **argv)
|
|||||||
gettimeofday(&timev, NULL);
|
gettimeofday(&timev, NULL);
|
||||||
t1 = (double)timev.tv_sec + (((double)timev.tv_usec)/1000000);
|
t1 = (double)timev.tv_sec + (((double)timev.tv_usec)/1000000);
|
||||||
if (i%3==0)
|
if (i%3==0)
|
||||||
imgh = RRenderMultiGradient(250, 250, colors, RGRD_HORIZONTAL);
|
imgh = RRenderMultiGradient(550, 550, colors, RGRD_HORIZONTAL);
|
||||||
else if (i%3==1)
|
else if (i%3==1)
|
||||||
imgh = RRenderMultiGradient(250, 250, colors, RGRD_VERTICAL);
|
imgh = RRenderMultiGradient(550, 550, colors, RGRD_VERTICAL);
|
||||||
else
|
else
|
||||||
imgh = RRenderMultiGradient(250, 250, colors, RGRD_DIAGONAL);
|
imgh = RRenderMultiGradient(550, 550, colors, RGRD_DIAGONAL);
|
||||||
|
|
||||||
gettimeofday(&timev, NULL);
|
gettimeofday(&timev, NULL);
|
||||||
t2 = (double)timev.tv_sec + (((double)timev.tv_usec)/1000000);
|
t2 = (double)timev.tv_sec + (((double)timev.tv_usec)/1000000);
|
||||||
|
|||||||
15
wrlib/view.c
15
wrlib/view.c
@@ -9,6 +9,8 @@ RContext *ctx;
|
|||||||
RImage *img;
|
RImage *img;
|
||||||
Pixmap pix;
|
Pixmap pix;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
RContextAttributes attr;
|
RContextAttributes attr;
|
||||||
@@ -19,7 +21,7 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
attr.flags = RC_RenderMode | RC_ColorsPerChannel;
|
attr.flags = RC_RenderMode | RC_ColorsPerChannel;
|
||||||
attr.render_mode = RM_DITHER;
|
attr.render_mode = RDitheredRendering;
|
||||||
attr.colors_per_channel = 4;
|
attr.colors_per_channel = 4;
|
||||||
ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
|
ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
|
||||||
if (argc<2)
|
if (argc<2)
|
||||||
@@ -31,18 +33,27 @@ int main(int argc, char **argv)
|
|||||||
puts(RMessageForError(RErrorCode));
|
puts(RMessageForError(RErrorCode));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
RImage *tmp = img;
|
RImage *tmp = img;
|
||||||
|
|
||||||
img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
|
img = RSmoothScaleImage(tmp, tmp->width*atol(argv[2]),
|
||||||
tmp->height*atol(argv[2]));
|
tmp->height*atol(argv[2]));
|
||||||
RDestroyImage(tmp);
|
RDestroyImage(tmp);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (argc > 2) {
|
||||||
|
img = RScaleImage(img, img->width*atof(argv[2]),
|
||||||
|
img->height*atof(argv[2]));
|
||||||
}
|
}
|
||||||
if (!RConvertImage(ctx, img, &pix)) {
|
if (!RConvertImage(ctx, img, &pix)) {
|
||||||
puts(RMessageForError(RErrorCode));
|
puts(RMessageForError(RErrorCode));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, img->width,
|
|
||||||
|
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10,
|
||||||
|
img->width,
|
||||||
img->height, 0, 0, 0);
|
img->height, 0, 0, 0);
|
||||||
RDestroyImage(img);
|
RDestroyImage(img);
|
||||||
XSetWindowBackgroundPixmap(dpy, win, pix);
|
XSetWindowBackgroundPixmap(dpy, win, pix);
|
||||||
|
|||||||
@@ -322,7 +322,8 @@ void RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy,
|
|||||||
|
|
||||||
RImage *RScaleImage(RImage *image, unsigned new_width, unsigned new_height);
|
RImage *RScaleImage(RImage *image, unsigned new_width, unsigned new_height);
|
||||||
|
|
||||||
RImage *RSmoothScaleImage(RImage *src, int newWidth, int newHeight);
|
RImage *RSmoothScaleImage(RImage *src, unsigned new_width,
|
||||||
|
unsigned new_height);
|
||||||
|
|
||||||
RImage *RMakeTiledImage(RImage *tile, unsigned width, unsigned height);
|
RImage *RMakeTiledImage(RImage *tile, unsigned width, unsigned height);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user