f-spot r4293 - in trunk: . src src/Widgets
- From: rubenv svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4293 - in trunk: . src src/Widgets
- Date: Mon, 25 Aug 2008 17:50:39 +0000 (UTC)
Author: rubenv
Date: Mon Aug 25 17:50:39 2008
New Revision: 4293
URL: http://svn.gnome.org/viewvc/f-spot?rev=4293&view=rev
Log:
2008-08-25 Ruben Vermeersch <ruben savanne be>
* src/Histogram.cs: More cleanups, fix a FIXME.
* src/Widgets/InfoBox.cs, src/Widgets/PreviewPopup.cs: Instead of filling
magic array items, use the new properties.
Modified:
trunk/ChangeLog
trunk/src/Histogram.cs
trunk/src/Widgets/InfoBox.cs
trunk/src/Widgets/PreviewPopup.cs
Modified: trunk/src/Histogram.cs
==============================================================================
--- trunk/src/Histogram.cs (original)
+++ trunk/src/Histogram.cs Mon Aug 25 17:50:39 2008
@@ -3,6 +3,7 @@
*
* Author(s):
* Larry Ewing <lewing novell com>
+ * Ruben Vermeersch <ruben savanne be>
*
* This is free software, See COPYING for details.
*/
@@ -11,18 +12,36 @@
namespace FSpot {
public class Histogram {
+#region Color hints
+ private byte [] colors = new byte [] {0x00, 0x00, 0x00, 0xff};
+
+ public byte RedColorHint {
+ set { colors [0] = value; }
+ }
+
+ public byte GreenColorHint {
+ set { colors [1] = value; }
+ }
+
+ public byte BlueColorHint {
+ set { colors [2] = value; }
+ }
+
+ public byte BackgroundColorHint {
+ set { colors [3] = value; }
+ }
+
+ private int [,] values = new int [256, 3];
+#endregion
+
public Histogram (Gdk.Pixbuf src)
{
FillValues (src);
}
public Histogram () {}
-
- // FIXME these should be properties
- public byte [] Color = new byte [] {0x00, 0x00, 0x00, 0xff};
public void FillValues (Gdk.Pixbuf src)
-
{
values = new int [256, 3];
@@ -56,19 +75,19 @@
}
}
- private int Count (int channel)
+ private int ChannelSum (int channel)
{
- int count = 0;
+ int sum = 0;
for (int i = 0; i < values.GetLength (0); i++) {
- count += values [i, channel];
+ sum += values [i, channel];
}
- return count;
+ return sum;
}
public void GetHighLow (int channel, out int high, out int low)
{
- double total = Count (channel);
+ double total = ChannelSum (channel);
double current = 0.0;
double percentage;
double next_percentage;
@@ -126,10 +145,10 @@
int j = 0;
for (; j < height - top; j++) {
- pixels [0] = Color [0];
- pixels [1] = Color [1];
- pixels [2] = Color [2];
- pixels [3] = Color [3];
+ pixels [0] = colors [0];
+ pixels [1] = colors [1];
+ pixels [2] = colors [2];
+ pixels [3] = colors [3];
pixels += rowstride;
}
for (; j < height; j++) {
@@ -146,9 +165,9 @@
public Gdk.Pixbuf GeneratePixbuf (int max_width)
{
- Gdk.Pixbuf pixbuf = GeneratePixbuf ();
- Gdk.Pixbuf scaled = PixbufUtils.ScaleToMaxSize (pixbuf, max_width, 128);
- pixbuf.Dispose ();
+ Gdk.Pixbuf scaled;
+ using (Gdk.Pixbuf pixbuf = GeneratePixbuf ())
+ scaled = PixbufUtils.ScaleToMaxSize (pixbuf, max_width, 128);
return scaled;
}
@@ -156,11 +175,10 @@
{
int height = 128;
Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, values.GetLength (0), height);
- this.Draw (pixbuf);
+ Draw (pixbuf);
return pixbuf;
}
- private int [,] values = new int [256, 3];
#if FSPOT_HISTOGRAM_MAIN
public static void Main (string [] args)
Modified: trunk/src/Widgets/InfoBox.cs
==============================================================================
--- trunk/src/Widgets/InfoBox.cs (original)
+++ trunk/src/Widgets/InfoBox.cs Mon Aug 25 17:50:39 2008
@@ -137,10 +137,10 @@
Window window = MainWindow.Toplevel.Window;
Gdk.Color c = window.Style.Backgrounds [(int)Gtk.StateType.Active];
- histogram.Color [0] = (byte) (c.Red / 0xff);
- histogram.Color [1] = (byte) (c.Green / 0xff);
- histogram.Color [2] = (byte) (c.Blue / 0xff);
- histogram.Color [3] = 0xff;
+ histogram.RedColorHint = (byte) (c.Red / 0xff);
+ histogram.GreenColorHint = (byte) (c.Green / 0xff);
+ histogram.BlueColorHint = (byte) (c.Blue / 0xff);
+ histogram.BackgroundColorHint = 0xff;
Add (histogram_expander);
@@ -462,7 +462,6 @@
using (ImageFile img = ImageFile.Create (photo.DefaultVersionUri))
histogram_hint = img.Load (256, 256);
-
histogram.FillValues (histogram_hint);
int max = histogram_expander.Allocation.Width;
histogram_image.Pixbuf = histogram.GeneratePixbuf (max);
Modified: trunk/src/Widgets/PreviewPopup.cs
==============================================================================
--- trunk/src/Widgets/PreviewPopup.cs (original)
+++ trunk/src/Widgets/PreviewPopup.cs Mon Aug 25 17:50:39 2008
@@ -299,10 +299,10 @@
this.BorderWidth = 6;
hist = new FSpot.Histogram ();
- hist.Color [0] = 127;
- hist.Color [1] = 127;
- hist.Color [2] = 127;
- hist.Color [3] = 0xff;
+ hist.RedColorHint = 127;
+ hist.GreenColorHint = 127;
+ hist.BlueColorHint = 127;
+ hist.BackgroundColorHint = 0xff;
image = new Gtk.Image ();
image.CanFocus = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]