On Thu, 2008-09-18 at 22:45 -0400, Brian J. Murrell wrote:
> 
> Pixelate is next.

Find pixelate below...

> I wonder if I can find a nice easy pixelate algorithm
> to implement or if I will have to invent my own.

Heh.  Lazy man's pixelate: scale down then back up.  :-)

diff --exclude .svn -Nur 
../f-spot-0.5.0/extensions/Editors/PixelateEditor/Makefile 
./extensions/Editors/PixelateEditor/Makefile
--- ../f-spot-0.5.0/extensions/Editors/PixelateEditor/Makefile  1969-12-31 
19:00:00.000000000 -0500
+++ ./extensions/Editors/PixelateEditor/Makefile        2008-09-18 
22:53:32.000000000 -0400
@@ -0,0 +1,29 @@
+all: PixelateEditor.dll
+
+PACKAGES = \
+       -pkg:f-spot \
+       -pkg:gtk-sharp-2.0
+
+ASSEMBLIES = \
+       -r:Mono.Posix
+
+RESOURCES = \
+       -resource:PixelateEditor.addin.xml
+
+SOURCES = \
+       PixelateEditor.cs
+
+install: all
+       cp *.dll ~/.gnome2/f-spot/addins/
+
+mpack: PixelateEditor.dll
+       mautil p PixelateEditor.dll
+
+PixelateEditor.dll: $(SOURCES) PixelateEditor.addin.xml
+       gmcs -target:library $(SOURCES) $(PACKAGES) $(ASSEMBLIES) $(RESOURCES)
+
+clean:
+       rm -f *.dll *~ *.bak .mpack
+
+PHONY:
+       install clean all mpack
diff --exclude .svn -Nur 
../f-spot-0.5.0/extensions/Editors/PixelateEditor/PixelateEditor.addin.xml 
./extensions/Editors/PixelateEditor/PixelateEditor.addin.xml
--- ../f-spot-0.5.0/extensions/Editors/PixelateEditor/PixelateEditor.addin.xml  
1969-12-31 19:00:00.000000000 -0500
+++ ./extensions/Editors/PixelateEditor/PixelateEditor.addin.xml        
2008-09-18 22:53:08.000000000 -0400
@@ -0,0 +1,15 @@
+<Addin namespace="FSpot"
+       id="PixelateEditor"
+       version="0.5.0.0"
+       name="PixelateEditor"
+       description="Pixelates the image horizontally."
+       author="Ruben Vermeersch"
+       url="http://f-spot.org/Extensions";
+       category="Editors">
+       <Dependencies>
+               <Addin id="Core" version="0.5.0.0"/>
+       </Dependencies>
+       <Extension path = "/FSpot/Editors">
+               <Editor editor_type = "FSpot.Addins.Editors.PixelateEditor"/>
+       </Extension>
+</Addin>
diff --exclude .svn -Nur 
../f-spot-0.5.0/extensions/Editors/PixelateEditor/PixelateEditor.cs 
./extensions/Editors/PixelateEditor/PixelateEditor.cs
--- ../f-spot-0.5.0/extensions/Editors/PixelateEditor/PixelateEditor.cs 
1969-12-31 19:00:00.000000000 -0500
+++ ./extensions/Editors/PixelateEditor/PixelateEditor.cs       2008-09-18 
23:19:16.000000000 -0400
@@ -0,0 +1,35 @@
+/*
+ * PixelateEditor.cs
+ *
+ * Author(s)
+ *     Brian J. Murrell <[EMAIL PROTECTED]>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using FSpot;
+using FSpot.Editors;
+using Gdk;
+using Mono.Unix;
+
+namespace FSpot.Addins.Editors {
+    class PixelateEditor : Editor {
+        public PixelateEditor () : base (Catalog.GetString ("Pixelate"), 
"object-blackout") {
+                       CanHandleMultiple = true;
+        }
+
+        protected override Pixbuf Process (Pixbuf input, Cms.Profile 
input_profile) {
+                       Pixbuf output = input.Copy ();
+
+                       Pixbuf sub = new Pixbuf (output, State.Selection.x, 
State.Selection.y,
+                                       State.Selection.width, 
State.Selection.height);
+                       /* lazy man's pixelate: scale down and then back up */
+                       Pixbuf down = sub.ScaleSimple 
(State.Selection.width/75, State.Selection.height/75,
+                                       InterpType.Nearest);
+                       Pixbuf up = down.ScaleSimple (State.Selection.width, 
State.Selection.height,
+                                       InterpType.Nearest);
+                       up.CopyArea (0, 0, State.Selection.width, 
State.Selection.height, sub, 0, 0);
+                       return output;
+        }
+    }
+}

This editor writing is really quite simple.  Or so it appears.  I guess
maybe I will find out what I have done wrong when/if somebody reviews my
patches.

Cheers,
b.

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
F-spot-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/f-spot-list

Reply via email to