1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Some fixes from Alban

This commit is contained in:
dan
2000-01-16 02:08:38 +00:00
parent b7296cff16
commit e18cba4da9
3 changed files with 26 additions and 40 deletions

View File

@@ -2155,7 +2155,7 @@ wheelRender(W_ColorPanel *panel)
W_Screen *scr = WMWidgetScreen(panel->win); W_Screen *scr = WMWidgetScreen(panel->win);
int x,y; int x,y;
RImage *image; RImage *image;
unsigned char *rp, *gp, *bp; unsigned char *ptr;
RColor gray; RColor gray;
unsigned long ofs = 0; unsigned long ofs = 0;
unsigned char shift = getShift(sizeof(unsigned char)); unsigned char shift = getShift(sizeof(unsigned char));
@@ -2166,27 +2166,25 @@ wheelRender(W_ColorPanel *panel)
return; return;
} }
ptr = image->data;
/* TODO Make this transparent istead of gray */ /* TODO Make this transparent istead of gray */
gray.red = gray.green = gray.blue = 0xaa; gray.red = gray.blue = 0xae; gray.green = 0xaa;
for (y = 0; y < colorWheelSize+4; y++) { for (y = 0; y < colorWheelSize+4; y++) {
for (x = 0; x < colorWheelSize+4; x++) { for (x = 0; x < colorWheelSize+4; x++) {
rp = image->data + (ofs << shift);
gp = image->data + (ofs << shift) + 1;
bp = image->data + (ofs << shift) + 2;
if (wheelInsideColorWheel(panel, ofs)) { if (wheelInsideColorWheel(panel, ofs)) {
*rp = (unsigned char)(panel->wheelMtrx->values[ *(ptr++) = (unsigned char)(panel->wheelMtrx->values[
panel->wheelMtrx->data[0][ofs] ]); panel->wheelMtrx->data[0][ofs] ]);
*gp = (unsigned char)(panel->wheelMtrx->values[ *(ptr++) = (unsigned char)(panel->wheelMtrx->values[
panel->wheelMtrx->data[1][ofs] ]); panel->wheelMtrx->data[1][ofs] ]);
*bp = (unsigned char)(panel->wheelMtrx->values[ *(ptr++) = (unsigned char)(panel->wheelMtrx->values[
panel->wheelMtrx->data[2][ofs] ]); panel->wheelMtrx->data[2][ofs] ]);
} }
else { else {
*rp = (unsigned char)(gray.red); *(ptr++) = (unsigned char)(gray.red);
*gp = (unsigned char)(gray.green); *(ptr++) = (unsigned char)(gray.green);
*bp = (unsigned char)(gray.blue); *(ptr++) = (unsigned char)(gray.blue);
} }
ofs++; ofs++;
} }
@@ -2914,35 +2912,30 @@ customRenderSpectrum(W_ColorPanel *panel)
{ {
RImage *spectrum; RImage *spectrum;
int x,y; int x,y;
unsigned long ofs; unsigned char *ptr;
unsigned char *rp, *gp, *bp;
CPColor cpColor; CPColor cpColor;
spectrum = RCreateImage(SPECTRUM_WIDTH, SPECTRUM_HEIGHT, 0); spectrum = RCreateImage(SPECTRUM_WIDTH, SPECTRUM_HEIGHT, False);
for (y=0; y<360; y++) { ptr = spectrum->data;
for (y = 0; y < SPECTRUM_HEIGHT; y++) {
cpColor.hsv.hue = y; cpColor.hsv.hue = y;
cpColor.hsv.saturation = 0; cpColor.hsv.saturation = 0;
cpColor.hsv.value = 255; cpColor.hsv.value = 255;
cpColor.set = cpHSV; cpColor.set = cpHSV;
for (x=0; x<511; x++) { for (x = 0; x < SPECTRUM_WIDTH; x++) {
ofs = (y * 511) + x;
convertCPColor(&cpColor); convertCPColor(&cpColor);
rp = spectrum->data + ofs; *(ptr++) = (unsigned char)cpColor.rgb.red;
gp = spectrum->data + ofs + 1; *(ptr++) = (unsigned char)cpColor.rgb.green;
bp = spectrum->data + ofs + 2; *(ptr++) = (unsigned char)cpColor.rgb.blue;
*rp = (unsigned char)cpColor.rgb.red; if (x < (SPECTRUM_WIDTH/2))
*gp = (unsigned char)cpColor.rgb.green;
*bp = (unsigned char)cpColor.rgb.blue;
if (x<255)
cpColor.hsv.saturation++; cpColor.hsv.saturation++;
if (x>255) if (x > (SPECTRUM_WIDTH/2))
cpColor.hsv.value--; cpColor.hsv.value--;
} }
} }
@@ -2965,7 +2958,6 @@ customSetPalette(W_ColorPanel *panel)
image = XCreatePixmap(scr->display, W_DRAWABLE(scr), customPaletteWidth, image = XCreatePixmap(scr->display, W_DRAWABLE(scr), customPaletteWidth,
customPaletteHeight, scr->depth); customPaletteHeight, scr->depth);
scaledImg = RScaleImage(panel->customPaletteImg, customPaletteWidth, scaledImg = RScaleImage(panel->customPaletteImg, customPaletteWidth,
customPaletteHeight); customPaletteHeight);
RConvertImage(scr->rcontext, scaledImg, &image); RConvertImage(scr->rcontext, scaledImg, &image);
@@ -3012,7 +3004,7 @@ customPalettePositionSelection(W_ColorPanel *panel, int x, int y)
panel->paly = y; panel->paly = y;
ofs = rint(x * panel->palXRatio) + rint(y * panel->palYRatio) * ofs = rint(x * panel->palXRatio) + rint(y * panel->palYRatio) *
panel->customPaletteImg->width; panel->customPaletteImg->width * 3;
panel->color.rgb.red = panel->customPaletteImg->data[ofs]; panel->color.rgb.red = panel->customPaletteImg->data[ofs];
panel->color.rgb.green = panel->customPaletteImg->data[ofs+1]; panel->color.rgb.green = panel->customPaletteImg->data[ofs+1];

View File

@@ -468,12 +468,6 @@ loadPixmaps(WMScreen *scr)
RCombineImageWithColor(tmp, &gray); RCombineImageWithColor(tmp, &gray);
scr->magnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128); scr->magnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
RDestroyImage(tmp); RDestroyImage(tmp);
/*
tmp = RGetSubImage(image, 24, 0, 40, 32);
RCombineImageWithColor(tmp, &white);
scr->altMagnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128);
RDestroyImage(tmp);
*/
/* ColorWheel Icon for ColorPanel */ /* ColorWheel Icon for ColorPanel */
tmp = RGetSubImage(image, 0, 25, 24, 24); tmp = RGetSubImage(image, 0, 25, 24, 24);
scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128); scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128);

View File

@@ -119,7 +119,7 @@ RGetSubImage(RImage *image, int x, int y, unsigned width, unsigned height)
total_line_size = image->width * (HAS_ALPHA(image) ? 4 : 3); total_line_size = image->width * (HAS_ALPHA(image) ? 4 : 3);
line_size = width * (HAS_ALPHA(image) ? 4 : 3); line_size = width * (HAS_ALPHA(image) ? 4 : 3);
ofs = x*(HAS_ALPHA(image) ? 4 : 3); ofs = x*(HAS_ALPHA(image) ? 4 : 3) + y*total_line_size;;
for (i=0; i<height; i++) { for (i=0; i<height; i++) {
memcpy(&new_image->data[i*line_size], memcpy(&new_image->data[i*line_size],
@@ -500,11 +500,11 @@ RMakeTiledImage(RImage *tile, unsigned width, unsigned height)
w = (width - x < tile->width) ? width - x : tile->width; w = (width - x < tile->width) ? width - x : tile->width;
if (has_alpha) { if (has_alpha) {
w *= 3;
memcpy(d, s+tx*3, w);
} else {
w *= 4; w *= 4;
memcpy(d, s+tx*4, w); memcpy(d, s+tx*4, w);
} else {
w *= 3;
memcpy(d, s+tx*3, w);
} }
d += w; d += w;
} }