[DEVELOPMENT ENVIRONMENT]

* BUG: Image.Mirror() now works in place.

[GB.GTK]
* NEW: Color.LightForeground has been implemented.


git-svn-id: svn://localhost/gambas/trunk@2297 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2009-09-01 09:29:40 +00:00
parent ac548e8734
commit f0b39ad212
11 changed files with 91 additions and 6138 deletions

6079
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ colon, a space, and the text.
Slots are the name of the component, in uppercase if possible, or some other Slots are the name of the component, in uppercase if possible, or some other
slots like [INTERPRETER], [COMPILER]... slots like [INTERPRETER], [COMPILER]...
All lines must be lower or equal than 76 characters. All lines lengths must be lower or equal than 76 characters.
If a changelog modification is more than one line, you must use a two space If a changelog modification is more than one line, you must use a two space
indent. indent.

View File

@ -288,7 +288,7 @@ Private Sub InitUser()
DrawText(.Name, 0, 0, W, H, Color.Merge(.Color, Color.White, 0.7), Color.Default) DrawText(.Name, 0, 0, W, H, Color.Merge(.Color, Color.White, 0.7), Color.Default)
Draw.End Draw.End
.Image = hPict.Image .Image = hPict.Image
.Image.MakeTransparent .Image.Transparent
End With End With
Next Next

View File

@ -398,11 +398,8 @@ Public Sub timMadeIn_Timer()
'If Me.Minimized Then Return 'If Me.Minimized Then Return
If $eIncAng < 0 Then hImage = $hLogo.Copy()
hImage = $hLogo.Mirror(True, False) If $eIncAng < 0 Then hImage.Mirror(True, False)
Else
hImage = $hLogo.Copy()
Endif
hMadeIn = $hMadeIn.Rotate(Rad($eAng)) hMadeIn = $hMadeIn.Rotate(Rad($eAng))
hImage.Draw(hMadeIn, - (hMadeIn.W - hImage.W) / 2, - (hMadeIn.H - hImage.H) / 2) hImage.Draw(hMadeIn, - (hMadeIn.W - hImage.W) / 2, - (hMadeIn.H - hImage.H) / 2)
$hDraw = hImage.Picture $hDraw = hImage.Picture

View File

@ -94,6 +94,17 @@ BEGIN_PROPERTY(CCOLOR_button_foreground)
END_PROPERTY END_PROPERTY
BEGIN_PROPERTY(CCOLOR_light_foreground)
uint col;
col = IMAGE.MergeColor(gDesktop::bgColor(), gDesktop::fgColor(), 0.5);
col = IMAGE.LighterColor(col);
GB.ReturnInteger(col);
END_PROPERTY
GB_DESC CColorDesc[] = GB_DESC CColorDesc[] =
{ {
GB_DECLARE("Color", 0), GB_VIRTUAL_CLASS(), GB_DECLARE("Color", 0), GB_VIRTUAL_CLASS(),
@ -106,6 +117,7 @@ GB_DESC CColorDesc[] =
GB_STATIC_PROPERTY("Foreground", "i", CCOLOR_foreground), GB_STATIC_PROPERTY("Foreground", "i", CCOLOR_foreground),
GB_STATIC_PROPERTY("SelectedForeground", "i", CCOLOR_selected_foreground), GB_STATIC_PROPERTY("SelectedForeground", "i", CCOLOR_selected_foreground),
GB_STATIC_PROPERTY("LightForeground", "i", CCOLOR_light_foreground),
GB_STATIC_PROPERTY("TextForeground", "i", CCOLOR_text_foreground), GB_STATIC_PROPERTY("TextForeground", "i", CCOLOR_text_foreground),
GB_STATIC_PROPERTY("ButtonForeground", "i", CCOLOR_button_foreground), GB_STATIC_PROPERTY("ButtonForeground", "i", CCOLOR_button_foreground),

View File

@ -27,6 +27,7 @@
#include <qpalette.h> #include <qpalette.h>
#include "gambas.h" #include "gambas.h"
#include "gb.image.h"
#include "CWidget.h" #include "CWidget.h"
#include "CColor.h" #include "CColor.h"
@ -37,12 +38,7 @@ static int _v = 0;
QColor CCOLOR_merge(const QColor &colorA, const QColor &colorB, int factor) QColor CCOLOR_merge(const QColor &colorA, const QColor &colorB, int factor)
{ {
const int maxFactor = 100; return QColor(IMAGE.MergeColor(colorA.rgba(), colorB.rgba(), factor / 100.0));
QColor tmp = colorA;
tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
return tmp;
} }
static void get_hsv(int col) static void get_hsv(int col)
@ -131,8 +127,12 @@ END_PROPERTY
BEGIN_PROPERTY(CCOLOR_light_foreground) BEGIN_PROPERTY(CCOLOR_light_foreground)
QColor col = CCOLOR_merge(qApp->palette().color(QPalette::Window), qApp->palette().color(QPalette::WindowText)).lighter(); uint col;
GB.ReturnInteger(col.rgb() & 0xFFFFFF);
col = IMAGE.MergeColor(qApp->palette().color(QPalette::Window).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::WindowText).rgb() & 0xFFFFFF, 0.5);
col = IMAGE.LighterColor(col);
GB.ReturnInteger(col);
END_PROPERTY END_PROPERTY

View File

@ -67,7 +67,7 @@ END_PROPERTY
BEGIN_METHOD(CIMAGE_fill, GB_INTEGER col) BEGIN_METHOD(CIMAGE_fill, GB_INTEGER col)
IMAGE_fill(THIS_IMAGE, VARG(col)); IMAGE_fill(THIS_IMAGE, VARG(col));
GB.ReturnObject(THIS); GB.ReturnObject(THIS);
END_METHOD END_METHOD
@ -92,7 +92,7 @@ END_PROPERTY
BEGIN_METHOD_VOID(CIMAGE_gray) BEGIN_METHOD_VOID(CIMAGE_gray)
IMAGE_make_gray(THIS_IMAGE); IMAGE_make_gray(THIS_IMAGE);
GB.ReturnObject(THIS); GB.ReturnObject(THIS);
END_METHOD END_METHOD
@ -105,21 +105,21 @@ END_METHOD
BEGIN_METHOD(CIMAGE_replace, GB_INTEGER src; GB_INTEGER dst; GB_BOOLEAN noteq) BEGIN_METHOD(CIMAGE_replace, GB_INTEGER src; GB_INTEGER dst; GB_BOOLEAN noteq)
IMAGE_replace(THIS_IMAGE, VARG(src), VARG(dst), VARGOPT(noteq, FALSE)); IMAGE_replace(THIS_IMAGE, VARG(src), VARG(dst), VARGOPT(noteq, FALSE));
GB.ReturnObject(THIS); GB.ReturnObject(THIS);
END_METHOD END_METHOD
BEGIN_METHOD(CIMAGE_transparent, GB_INTEGER color) BEGIN_METHOD(CIMAGE_transparent, GB_INTEGER color)
IMAGE_make_transparent(THIS_IMAGE, VARGOPT(color, 0xFFFFFF)); IMAGE_make_transparent(THIS_IMAGE, VARGOPT(color, 0xFFFFFF));
GB.ReturnObject(THIS); GB.ReturnObject(THIS);
END_METHOD END_METHOD
BEGIN_METHOD(CIMAGE_colorize, GB_INTEGER color) BEGIN_METHOD(CIMAGE_colorize, GB_INTEGER color)
IMAGE_colorize(THIS_IMAGE, VARG(color)); IMAGE_colorize(THIS_IMAGE, VARG(color));
GB.ReturnObject(THIS); GB.ReturnObject(THIS);
END_METHOD END_METHOD

View File

@ -180,6 +180,50 @@ void COLOR_hsv_to_rgb(int h, int s, int v, int *R, int *G, int *B)
} }
} }
GB_COLOR COLOR_merge(GB_COLOR col1, GB_COLOR col2, double weight)
{
int a, r, g, b;
if (weight == 0.0)
return col1;
else if (weight == 1.0)
return col2;
else
{
#define MIX_COLOR(_shift) (int)((((col2 >> _shift) & 0xFF) * weight + ((col1 >> _shift) & 0xFF) * (1 - weight)) + 0.5)
a = MIX_COLOR(24);
r = MIX_COLOR(16);
g = MIX_COLOR(8);
b = MIX_COLOR(0);
return gt_rgba_to_color(r, g, b, a);
}
}
GB_COLOR COLOR_lighter(GB_COLOR color)
{
int h, s, v;
int r, g, b, a;
gt_color_to_rgba(color, &r, &g, &b, &a);
COLOR_rgb_to_hsv(r, g, b, &h, &s, &v);
COLOR_hsv_to_rgb(h, s / 2, 255 - (255 - v) / 2, &r, &g, &b);
return gt_rgba_to_color(r, g, b, a);
}
GB_COLOR COLOR_darker(GB_COLOR color)
{
int h, s, v;
int r, g, b, a;
gt_color_to_rgba(color, &r, &g, &b, &a);
COLOR_rgb_to_hsv(r, g, b, &h, &s, &v);
COLOR_hsv_to_rgb(h, 255 - (255 - s) / 2, v / 2, &r, &g, &b);
return gt_rgba_to_color(r, g, b, a);
}
BEGIN_METHOD(CCOLOR_rgb, GB_INTEGER r; GB_INTEGER g; GB_INTEGER b; GB_INTEGER a) BEGIN_METHOD(CCOLOR_rgb, GB_INTEGER r; GB_INTEGER g; GB_INTEGER b; GB_INTEGER a)
@ -255,54 +299,19 @@ END_PROPERTY
BEGIN_METHOD(CCOLOR_lighter, GB_INTEGER color) BEGIN_METHOD(CCOLOR_lighter, GB_INTEGER color)
int h, s, v; GB.ReturnInteger(COLOR_lighter(VARG(color)));
int r, g, b, a;
gt_color_to_rgba(VARG(color), &r, &g, &b, &a);
COLOR_rgb_to_hsv(r, g, b, &h, &s, &v);
COLOR_hsv_to_rgb(h, s / 2, 255 - (255 - v) / 2, &r, &g, &b);
GB.ReturnInteger(gt_rgba_to_color(r, g, b, a));
END_METHOD END_METHOD
BEGIN_METHOD(CCOLOR_darker, GB_INTEGER color) BEGIN_METHOD(CCOLOR_darker, GB_INTEGER color)
int h, s, v; GB.ReturnInteger(COLOR_darker(VARG(color)));
int r, g, b, a;
gt_color_to_rgba(VARG(color), &r, &g, &b, &a);
COLOR_rgb_to_hsv(r, g, b, &h, &s, &v);
COLOR_hsv_to_rgb(h, 255 - (255 - s) / 2, v / 2, &r, &g, &b);
GB.ReturnInteger(gt_rgba_to_color(r, g, b, a));
END_METHOD END_METHOD
BEGIN_METHOD(CCOLOR_mix, GB_INTEGER color1; GB_INTEGER color2; GB_FLOAT weight) BEGIN_METHOD(CCOLOR_merge, GB_INTEGER color1; GB_INTEGER color2; GB_FLOAT weight)
int col1, col2; GB.ReturnInteger(COLOR_merge(VARG(color1), VARG(color2), VARGOPT(weight, 0.5)));
int r, g, b, a;
double weight = VARGOPT(weight, 0.5);
col1 = VARG(color1);
col2 = VARG(color2);
if (weight == 0.0)
GB.ReturnInteger(col1);
else if (weight == 1.0)
GB.ReturnInteger(col2);
else
{
#define MIX_COLOR(_shift) (int)((((col2 >> _shift) & 0xFF) * weight + ((col1 >> _shift) & 0xFF) * (1 - weight)) + 0.5)
a = MIX_COLOR(24);
r = MIX_COLOR(16);
g = MIX_COLOR(8);
b = MIX_COLOR(0);
GB.ReturnInteger(gt_rgba_to_color(r, g, b, a));
}
END_METHOD END_METHOD
@ -408,7 +417,7 @@ GB_DESC CColorDesc[] =
GB_STATIC_METHOD("Lighter", "i", CCOLOR_lighter, "(Color)i"), GB_STATIC_METHOD("Lighter", "i", CCOLOR_lighter, "(Color)i"),
GB_STATIC_METHOD("Darker", "i", CCOLOR_darker, "(Color)i"), GB_STATIC_METHOD("Darker", "i", CCOLOR_darker, "(Color)i"),
GB_STATIC_METHOD("Merge", "i", CCOLOR_mix, "(Color1)i(Color2)i[(Weight)f]"), GB_STATIC_METHOD("Merge", "i", CCOLOR_merge, "(Color1)i(Color2)i[(Weight)f]"),
GB_STATIC_METHOD("Blend", "i", CCOLOR_blend, "(Source)i(Destination)i"), GB_STATIC_METHOD("Blend", "i", CCOLOR_blend, "(Source)i(Destination)i"),
GB_STATIC_METHOD("_get", "ColorInfo", CCOLOR_get, "(Color)i"), GB_STATIC_METHOD("_get", "ColorInfo", CCOLOR_get, "(Color)i"),

View File

@ -41,5 +41,8 @@ typedef
void COLOR_rgb_to_hsv(int r, int g, int b, int *H, int *S, int *V); void COLOR_rgb_to_hsv(int r, int g, int b, int *H, int *S, int *V);
void COLOR_hsv_to_rgb(int h, int s, int v, int *R, int *G, int *B); void COLOR_hsv_to_rgb(int h, int s, int v, int *R, int *G, int *B);
GB_COLOR COLOR_merge(GB_COLOR col1, GB_COLOR col2, double weight);
GB_COLOR COLOR_lighter(GB_COLOR color);
GB_COLOR COLOR_darker(GB_COLOR color);
#endif #endif

View File

@ -125,6 +125,12 @@ typedef
GB_COLOR (*GetPixel)(GB_IMG *img, int x, int y); GB_COLOR (*GetPixel)(GB_IMG *img, int x, int y);
// Converts an image to one of the following formats: BGRA, RGBA, BGRP, RGBP // Converts an image to one of the following formats: BGRA, RGBA, BGRP, RGBP
void (*Convert)(GB_IMG *img, int format); void (*Convert)(GB_IMG *img, int format);
// Merge two colors
GB_COLOR (*MergeColor)(GB_COLOR col1, GB_COLOR col2, double weight);
// Make a color lighter
GB_COLOR (*LighterColor)(GB_COLOR col);
// Make a color darker
GB_COLOR (*DarkerColor)(GB_COLOR col);
} }
IMAGE_INTERFACE; IMAGE_INTERFACE;

View File

@ -63,6 +63,9 @@ void *GB_IMAGE_1[] EXPORT =
(void *)IMAGE_get_default_format, (void *)IMAGE_get_default_format,
(void *)IMAGE_get_pixel, (void *)IMAGE_get_pixel,
(void *)IMAGE_convert, (void *)IMAGE_convert,
(void *)COLOR_merge,
(void *)COLOR_lighter,
(void *)COLOR_darker,
NULL NULL
}; };