]> gitweb.factorcode.org Git - factor.git/commitdiff
Rename images.gtk|gdiplus|cocoa to images.loader.*. Fixes #176.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 2 Nov 2011 16:38:03 +0000 (09:38 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 2 Nov 2011 16:38:03 +0000 (09:38 -0700)
21 files changed:
basis/images/cocoa/authors.txt [deleted file]
basis/images/cocoa/cocoa.factor [deleted file]
basis/images/cocoa/platforms.txt [deleted file]
basis/images/cocoa/summary.txt [deleted file]
basis/images/gdiplus/gdiplus.factor [deleted file]
basis/images/gdiplus/platforms.txt [deleted file]
basis/images/gtk/authors.txt [deleted file]
basis/images/gtk/gtk.factor [deleted file]
basis/images/gtk/platforms.txt [deleted file]
basis/images/gtk/summary.txt [deleted file]
basis/images/loader/cocoa/authors.txt [new file with mode: 0644]
basis/images/loader/cocoa/cocoa.factor [new file with mode: 0644]
basis/images/loader/cocoa/platforms.txt [new file with mode: 0644]
basis/images/loader/cocoa/summary.txt [new file with mode: 0644]
basis/images/loader/gdiplus/gdiplus.factor [new file with mode: 0644]
basis/images/loader/gdiplus/platforms.txt [new file with mode: 0644]
basis/images/loader/gtk/authors.txt [new file with mode: 0644]
basis/images/loader/gtk/gtk.factor [new file with mode: 0644]
basis/images/loader/gtk/platforms.txt [new file with mode: 0644]
basis/images/loader/gtk/summary.txt [new file with mode: 0644]
basis/ui/images/images.factor

diff --git a/basis/images/cocoa/authors.txt b/basis/images/cocoa/authors.txt
deleted file mode 100644 (file)
index f13c9c1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Joe Groff
diff --git a/basis/images/cocoa/cocoa.factor b/basis/images/cocoa/cocoa.factor
deleted file mode 100644 (file)
index 449dab2..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-! Copyright (C) 2010, 2011 Joe Groff, Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.data cocoa cocoa.classes cocoa.messages
-combinators core-foundation.data core-graphics
-core-graphics.types fry locals images images.loader io kernel
-math sequences ;
-FROM: system => os macosx? ;
-IN: images.cocoa
-
-SINGLETON: ns-image
-
-os macosx? [
-    "png" ns-image register-image-class
-    "tif" ns-image register-image-class
-    "tiff" ns-image register-image-class
-    "gif" ns-image register-image-class
-    "jpg" ns-image register-image-class
-    "jpeg" ns-image register-image-class
-    "bmp" ns-image register-image-class
-    "ico" ns-image register-image-class
-] when
-
-: <CGImage> ( byte-array -- image-rep )
-    [ NSBitmapImageRep ] dip
-    <CFData> -> autorelease
-    -> imageRepWithData:
-    -> CGImage ;
-
-:: CGImage>image ( image -- image )
-    image CGImageGetWidth :> w
-    image CGImageGetHeight :> h
-    { w h } [
-        0 0 w h <CGRect> image CGContextDrawImage
-    ] make-bitmap-image ;
-
-M: ns-image stream>image
-    drop stream-contents <CGImage> CGImage>image ;
diff --git a/basis/images/cocoa/platforms.txt b/basis/images/cocoa/platforms.txt
deleted file mode 100644 (file)
index 6e806f4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-macosx
diff --git a/basis/images/cocoa/summary.txt b/basis/images/cocoa/summary.txt
deleted file mode 100644 (file)
index 628cce9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Image loading using MacOS X's native Cocoa APIs
diff --git a/basis/images/gdiplus/gdiplus.factor b/basis/images/gdiplus/gdiplus.factor
deleted file mode 100644 (file)
index 1bdb652..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-! (c)2010 Joe Groff bsd license\r
-USING: accessors alien.c-types alien.data alien.enums\r
-classes.struct destructors images images.loader kernel locals\r
-math windows.com windows.gdiplus windows.streams windows.types\r
-typed byte-arrays grouping sequences ;\r
-FROM: system => os windows? ;\r
-IN: images.gdiplus\r
-\r
-SINGLETON: gdi+-image\r
-\r
-os windows? [\r
-    "png" gdi+-image register-image-class\r
-    "tif" gdi+-image register-image-class\r
-    "tiff" gdi+-image register-image-class\r
-    "gif" gdi+-image register-image-class\r
-    "jpg" gdi+-image register-image-class\r
-    "jpeg" gdi+-image register-image-class\r
-    "bmp" gdi+-image register-image-class\r
-    "ico" gdi+-image register-image-class\r
-] when\r
-\r
-<PRIVATE\r
-: <GpRect> ( x y w h -- rect )\r
-    GpRect <struct-boa> ; inline\r
-\r
-: stream>gdi+-bitmap ( stream -- bitmap )\r
-    stream>IStream &com-release\r
-    { void* } [ GdipCreateBitmapFromStream check-gdi+-status ]\r
-    with-out-parameters &GdipFree ;\r
-\r
-: gdi+-bitmap-width ( bitmap -- w )\r
-    { UINT } [ GdipGetImageWidth check-gdi+-status ]\r
-    with-out-parameters ;\r
-: gdi+-bitmap-height ( bitmap -- w )\r
-    { UINT } [ GdipGetImageHeight check-gdi+-status ]\r
-    with-out-parameters ;\r
-: gdi+-lock-bitmap ( bitmap rect mode format -- data )\r
-    { BitmapData } [ GdipBitmapLockBits check-gdi+-status ]\r
-    with-out-parameters ;\r
-\r
-:: gdi+-bitmap>data ( bitmap -- w h pixels )\r
-    bitmap [ gdi+-bitmap-width ] [ gdi+-bitmap-height ] bi :> ( w h )\r
-    bitmap 0 0 w h <GpRect> ImageLockModeRead enum>number\r
-    PixelFormat32bppARGB gdi+-lock-bitmap :> bitmap-data\r
-    bitmap-data [ Scan0>> ] [ Stride>> ] [ Height>> * ] tri\r
-    memory>byte-array :> pixels\r
-    bitmap bitmap-data GdipBitmapUnlockBits check-gdi+-status\r
-    w h pixels ;\r
-    \r
-:: data>image ( w h pixels -- image )\r
-    image new\r
-        { w h } >>dim\r
-        pixels >>bitmap\r
-        BGRA >>component-order\r
-        ubyte-components >>component-type\r
-        f >>upside-down? ;\r
-\r
-PRIVATE>\r
-\r
-M: gdi+-image stream>image\r
-    drop [\r
-        start-gdi+ &stop-gdi+ drop\r
-        stream>gdi+-bitmap\r
-        gdi+-bitmap>data\r
-        data>image\r
-    ] with-destructors ;\r
diff --git a/basis/images/gdiplus/platforms.txt b/basis/images/gdiplus/platforms.txt
deleted file mode 100644 (file)
index 8e1a559..0000000
+++ /dev/null
@@ -1 +0,0 @@
-windows
diff --git a/basis/images/gtk/authors.txt b/basis/images/gtk/authors.txt
deleted file mode 100644 (file)
index 156a81a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Philipp Brüschweiler
diff --git a/basis/images/gtk/gtk.factor b/basis/images/gtk/gtk.factor
deleted file mode 100644 (file)
index 95b677b..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-! Copyright (C) 2010 Philipp Brüschweiler.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types alien.data arrays combinators
-destructors gdk.pixbuf.ffi gobject.ffi grouping images
-images.loader io kernel locals math sequences
-specialized-arrays ;
-FROM: system => os linux freebsd netbsd openbsd ;
-IN: images.gtk
-SPECIALIZED-ARRAY: uchar
-
-SINGLETON: gtk-image
-
-os { linux freebsd netbsd openbsd } member? [
-    "png"  gtk-image register-image-class
-    "tif"  gtk-image register-image-class
-    "tiff" gtk-image register-image-class
-    "gif"  gtk-image register-image-class
-    "jpg"  gtk-image register-image-class
-    "jpeg" gtk-image register-image-class
-    "bmp"  gtk-image register-image-class
-    "ico"  gtk-image register-image-class
-] when
-
-<PRIVATE
-
-: image-data ( GdkPixbuf -- data )
-    {
-        [ gdk_pixbuf_get_pixels ]
-        [ gdk_pixbuf_get_width ]
-        [ gdk_pixbuf_get_height ]
-        [ gdk_pixbuf_get_rowstride ]
-        [ gdk_pixbuf_get_n_channels ]
-        [ gdk_pixbuf_get_bits_per_sample ]
-    } cleave
-    [let :> ( pixels w h rowstride channels bps )
-        bps channels * 7 + 8 /i w * :> bytes-per-row
-
-        bytes-per-row rowstride =
-        [ pixels h rowstride * memory>byte-array ]
-        [
-            pixels rowstride h * uchar <c-direct-array>
-            rowstride <sliced-groups>
-            [ bytes-per-row head-slice ] map concat
-        ] if
-    ] ;
-
-: component-type ( GdkPixbuf -- component-type )
-    gdk_pixbuf_get_bits_per_sample {
-        {  8 [ ubyte-components ] }
-        { 16 [ ushort-components ] }
-        { 32 [ uint-components ] }
-    } case ;
-
-: GdkPixbuf>image ( GdkPixbuf -- image )
-    [ image new ] dip
-        {
-            [ [ gdk_pixbuf_get_width ] [ gdk_pixbuf_get_height ] bi 2array >>dim ]
-            [ image-data >>bitmap ]
-            [ gdk_pixbuf_get_has_alpha RGBA RGB ? >>component-order ]
-            [ component-type >>component-type ]
-        } cleave
-        f >>premultiplied-alpha?
-        f >>upside-down? ;
-
-PRIVATE>
-
-M: gtk-image stream>image
-    drop [
-        stream-contents data>GInputStream &g_object_unref
-        GInputStream>GdkPixbuf &g_object_unref
-        GdkPixbuf>image
-    ] with-destructors ;
diff --git a/basis/images/gtk/platforms.txt b/basis/images/gtk/platforms.txt
deleted file mode 100644 (file)
index a26481a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-linux
-bsd
diff --git a/basis/images/gtk/summary.txt b/basis/images/gtk/summary.txt
deleted file mode 100644 (file)
index 7813e56..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Image loading using GTK's GdkPixbuf API
diff --git a/basis/images/loader/cocoa/authors.txt b/basis/images/loader/cocoa/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/basis/images/loader/cocoa/cocoa.factor b/basis/images/loader/cocoa/cocoa.factor
new file mode 100644 (file)
index 0000000..6680a4f
--- /dev/null
@@ -0,0 +1,37 @@
+! Copyright (C) 2010, 2011 Joe Groff, Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien.data cocoa cocoa.classes cocoa.messages
+combinators core-foundation.data core-graphics
+core-graphics.types fry locals images images.loader io kernel
+math sequences ;
+FROM: system => os macosx? ;
+IN: images.loader.cocoa
+
+SINGLETON: ns-image
+
+os macosx? [
+    "png" ns-image register-image-class
+    "tif" ns-image register-image-class
+    "tiff" ns-image register-image-class
+    "gif" ns-image register-image-class
+    "jpg" ns-image register-image-class
+    "jpeg" ns-image register-image-class
+    "bmp" ns-image register-image-class
+    "ico" ns-image register-image-class
+] when
+
+: <CGImage> ( byte-array -- image-rep )
+    [ NSBitmapImageRep ] dip
+    <CFData> -> autorelease
+    -> imageRepWithData:
+    -> CGImage ;
+
+:: CGImage>image ( image -- image )
+    image CGImageGetWidth :> w
+    image CGImageGetHeight :> h
+    { w h } [
+        0 0 w h <CGRect> image CGContextDrawImage
+    ] make-bitmap-image ;
+
+M: ns-image stream>image
+    drop stream-contents <CGImage> CGImage>image ;
diff --git a/basis/images/loader/cocoa/platforms.txt b/basis/images/loader/cocoa/platforms.txt
new file mode 100644 (file)
index 0000000..6e806f4
--- /dev/null
@@ -0,0 +1 @@
+macosx
diff --git a/basis/images/loader/cocoa/summary.txt b/basis/images/loader/cocoa/summary.txt
new file mode 100644 (file)
index 0000000..628cce9
--- /dev/null
@@ -0,0 +1 @@
+Image loading using MacOS X's native Cocoa APIs
diff --git a/basis/images/loader/gdiplus/gdiplus.factor b/basis/images/loader/gdiplus/gdiplus.factor
new file mode 100644 (file)
index 0000000..3ac0e2a
--- /dev/null
@@ -0,0 +1,66 @@
+! (c)2010 Joe Groff bsd license\r
+USING: accessors alien.c-types alien.data alien.enums\r
+classes.struct destructors images images.loader kernel locals\r
+math windows.com windows.gdiplus windows.streams windows.types\r
+typed byte-arrays grouping sequences ;\r
+FROM: system => os windows? ;\r
+IN: images.loader.gdiplus\r
+\r
+SINGLETON: gdi+-image\r
+\r
+os windows? [\r
+    "png" gdi+-image register-image-class\r
+    "tif" gdi+-image register-image-class\r
+    "tiff" gdi+-image register-image-class\r
+    "gif" gdi+-image register-image-class\r
+    "jpg" gdi+-image register-image-class\r
+    "jpeg" gdi+-image register-image-class\r
+    "bmp" gdi+-image register-image-class\r
+    "ico" gdi+-image register-image-class\r
+] when\r
+\r
+<PRIVATE\r
+: <GpRect> ( x y w h -- rect )\r
+    GpRect <struct-boa> ; inline\r
+\r
+: stream>gdi+-bitmap ( stream -- bitmap )\r
+    stream>IStream &com-release\r
+    { void* } [ GdipCreateBitmapFromStream check-gdi+-status ]\r
+    with-out-parameters &GdipFree ;\r
+\r
+: gdi+-bitmap-width ( bitmap -- w )\r
+    { UINT } [ GdipGetImageWidth check-gdi+-status ]\r
+    with-out-parameters ;\r
+: gdi+-bitmap-height ( bitmap -- w )\r
+    { UINT } [ GdipGetImageHeight check-gdi+-status ]\r
+    with-out-parameters ;\r
+: gdi+-lock-bitmap ( bitmap rect mode format -- data )\r
+    { BitmapData } [ GdipBitmapLockBits check-gdi+-status ]\r
+    with-out-parameters ;\r
+\r
+:: gdi+-bitmap>data ( bitmap -- w h pixels )\r
+    bitmap [ gdi+-bitmap-width ] [ gdi+-bitmap-height ] bi :> ( w h )\r
+    bitmap 0 0 w h <GpRect> ImageLockModeRead enum>number\r
+    PixelFormat32bppARGB gdi+-lock-bitmap :> bitmap-data\r
+    bitmap-data [ Scan0>> ] [ Stride>> ] [ Height>> * ] tri\r
+    memory>byte-array :> pixels\r
+    bitmap bitmap-data GdipBitmapUnlockBits check-gdi+-status\r
+    w h pixels ;\r
+    \r
+:: data>image ( w h pixels -- image )\r
+    image new\r
+        { w h } >>dim\r
+        pixels >>bitmap\r
+        BGRA >>component-order\r
+        ubyte-components >>component-type\r
+        f >>upside-down? ;\r
+\r
+PRIVATE>\r
+\r
+M: gdi+-image stream>image\r
+    drop [\r
+        start-gdi+ &stop-gdi+ drop\r
+        stream>gdi+-bitmap\r
+        gdi+-bitmap>data\r
+        data>image\r
+    ] with-destructors ;\r
diff --git a/basis/images/loader/gdiplus/platforms.txt b/basis/images/loader/gdiplus/platforms.txt
new file mode 100644 (file)
index 0000000..8e1a559
--- /dev/null
@@ -0,0 +1 @@
+windows
diff --git a/basis/images/loader/gtk/authors.txt b/basis/images/loader/gtk/authors.txt
new file mode 100644 (file)
index 0000000..156a81a
--- /dev/null
@@ -0,0 +1 @@
+Philipp Brüschweiler
diff --git a/basis/images/loader/gtk/gtk.factor b/basis/images/loader/gtk/gtk.factor
new file mode 100644 (file)
index 0000000..c395bca
--- /dev/null
@@ -0,0 +1,72 @@
+! Copyright (C) 2010 Philipp Brüschweiler.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien.c-types alien.data arrays combinators
+destructors gdk.pixbuf.ffi gobject.ffi grouping images
+images.loader io kernel locals math sequences
+specialized-arrays ;
+FROM: system => os linux freebsd netbsd openbsd ;
+IN: images.loader.gtk
+SPECIALIZED-ARRAY: uchar
+
+SINGLETON: gtk-image
+
+os { linux freebsd netbsd openbsd } member? [
+    "png"  gtk-image register-image-class
+    "tif"  gtk-image register-image-class
+    "tiff" gtk-image register-image-class
+    "gif"  gtk-image register-image-class
+    "jpg"  gtk-image register-image-class
+    "jpeg" gtk-image register-image-class
+    "bmp"  gtk-image register-image-class
+    "ico"  gtk-image register-image-class
+] when
+
+<PRIVATE
+
+: image-data ( GdkPixbuf -- data )
+    {
+        [ gdk_pixbuf_get_pixels ]
+        [ gdk_pixbuf_get_width ]
+        [ gdk_pixbuf_get_height ]
+        [ gdk_pixbuf_get_rowstride ]
+        [ gdk_pixbuf_get_n_channels ]
+        [ gdk_pixbuf_get_bits_per_sample ]
+    } cleave
+    [let :> ( pixels w h rowstride channels bps )
+        bps channels * 7 + 8 /i w * :> bytes-per-row
+
+        bytes-per-row rowstride =
+        [ pixels h rowstride * memory>byte-array ]
+        [
+            pixels rowstride h * uchar <c-direct-array>
+            rowstride <sliced-groups>
+            [ bytes-per-row head-slice ] map concat
+        ] if
+    ] ;
+
+: component-type ( GdkPixbuf -- component-type )
+    gdk_pixbuf_get_bits_per_sample {
+        {  8 [ ubyte-components ] }
+        { 16 [ ushort-components ] }
+        { 32 [ uint-components ] }
+    } case ;
+
+: GdkPixbuf>image ( GdkPixbuf -- image )
+    [ image new ] dip
+        {
+            [ [ gdk_pixbuf_get_width ] [ gdk_pixbuf_get_height ] bi 2array >>dim ]
+            [ image-data >>bitmap ]
+            [ gdk_pixbuf_get_has_alpha RGBA RGB ? >>component-order ]
+            [ component-type >>component-type ]
+        } cleave
+        f >>premultiplied-alpha?
+        f >>upside-down? ;
+
+PRIVATE>
+
+M: gtk-image stream>image
+    drop [
+        stream-contents data>GInputStream &g_object_unref
+        GInputStream>GdkPixbuf &g_object_unref
+        GdkPixbuf>image
+    ] with-destructors ;
diff --git a/basis/images/loader/gtk/platforms.txt b/basis/images/loader/gtk/platforms.txt
new file mode 100644 (file)
index 0000000..a26481a
--- /dev/null
@@ -0,0 +1,2 @@
+linux
+bsd
diff --git a/basis/images/loader/gtk/summary.txt b/basis/images/loader/gtk/summary.txt
new file mode 100644 (file)
index 0000000..7813e56
--- /dev/null
@@ -0,0 +1 @@
+Image loading using GTK's GdkPixbuf API
index 74a7be2bb1446311eac47a4aef0c9f8c14a6a1c9..4a23f1c5267dda241a8ca7ba6373283728864eb1 100644 (file)
@@ -33,8 +33,8 @@ PRIVATE>
 
 <<
 {
-    { [ os macosx? ] [ "images.cocoa"   require ] }
-    { [ os windows?  ] [ "images.gdiplus" require ] }
-    [ "images.gtk" require ]
+    { [ os macosx? ] [ "images.loader.cocoa"   require ] }
+    { [ os windows?  ] [ "images.loader.gdiplus" require ] }
+    [ "images.loader.gtk" require ]
 } cond
 >>