aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2015-08-24 01:28:28 +0200
committerCamil Staps2015-08-24 01:28:28 +0200
commit447c0f0d09cd8a5555ee8f4b199f0de7013ed304 (patch)
tree9e35a9347e139c55c325954bf252916f9576a4af
parentImplemented GETCLIPBOARDCOUNT; fix C warning (diff)
Ugly hack to get winCreateBitmap to work
Typically, we would do this with gdk_pixbuf_from_file(). However, the openBitmap function from StdBitmap only gives us a *File, not the file name. So, we cannot read from the file itself directly. Therefore, we now create a temporary file with the same content and read from there. Ideally, StdBitmap would be edited to pass both a *File and a !{#Char} with the file name (or just the latter, and let osbitmap decide what to do with it).
-rw-r--r--Linux_C_12/cpicture_121.c25
-rw-r--r--Linux_C_12/cpicture_121.h2
-rw-r--r--osbitmap.icl2
-rw-r--r--pictCCall_12.dcl2
-rw-r--r--pictCCall_12.icl78
5 files changed, 59 insertions, 50 deletions
diff --git a/Linux_C_12/cpicture_121.c b/Linux_C_12/cpicture_121.c
index 68f19e5..c430d46 100644
--- a/Linux_C_12/cpicture_121.c
+++ b/Linux_C_12/cpicture_121.c
@@ -14,6 +14,7 @@
#include "cpicture_121.h"
#include "cCrossCall_121.h"
#include "cCrossCallWindows_121.h"
+#include "Clean.h"
extern void InitGTK();
@@ -1115,12 +1116,12 @@ void WinCreateScreenHDC(OS ios, GdkDrawable **outDraw, OS *oos)
*oos = ios;
*outDraw = GDK_DRAWABLE(theWindow);
- printf("WinCreateScreenHDC - %d\n",theWindow);
+ printf("WinCreateScreenHDC - %p\n",theWindow);
} /* WinCreateScreenHDC */
OS WinDestroyScreenHDC (GdkDrawable *drawable, OS os)
{
- printf("WinDestroyScreenHDC - %d\n",drawable);
+ printf("WinDestroyScreenHDC - %p\n",drawable);
/* g_object_unref(drawable); */
return os;
} /* WinDestroyScreenHDC */
@@ -1184,19 +1185,27 @@ void WinDrawBitmap (gint w, gint h, gint destx, gint desty, GdkPixbuf *pixbuf,
*oos = ios;
} /* WinDrawBitmap */
-void WinCreateBitmap (gint width, gchar *filename, GdkDrawable *inDraw,OS ios,
+void WinCreateBitmap (CLEAN_STRING data, GdkDrawable *inDraw,OS ios,
GdkPixbuf **bitmap, OS* oos)
{
GError *err = NULL;
+ char* cdata = cstring(data);
printf("WinCreateBitmap\n");
+
+ char* tempfile = "/tmp/bitmapXXXXXX";
+ int tempfh = mkstemp(tempfile);
+ if (tempfh == -1) {
+ printf("Couldn't create temporary file.\n");
+ exit(1);
+ }
+ write(tempfh, cdata, CleanStringLength(data));
+
InitGTK();
- *bitmap = gdk_pixbuf_new_from_file(filename, &err);
+ *bitmap = gdk_pixbuf_new_from_file(tempfile, &err);
- /*
- *pWidth = gdk_pixbuf_get_width(pixbuf);
- *pHeight = gdk_pixbuf_get_height(pixbuf);
- */
+ unlink(tempfile);
+ close(tempfh);
*oos = ios;
} /* WinCreateBitmap */
diff --git a/Linux_C_12/cpicture_121.h b/Linux_C_12/cpicture_121.h
index 68489a4..c9a403a 100644
--- a/Linux_C_12/cpicture_121.h
+++ b/Linux_C_12/cpicture_121.h
@@ -114,7 +114,7 @@ extern void WinDrawResizedBitmap (int,int,int,int,int,int,OSBmpHandle,
OSPictContext,OS,OSPictContext*,OS*);
extern void WinDrawBitmap (int,int,int,int,OSBmpHandle,OSPictContext,OS,
OSPictContext*,OS*);
-extern void WinCreateBitmap (int, char*,OSPictContext,OS,OSBmpHandle*,OS*);
+extern void WinCreateBitmap (CLEAN_STRING,OSPictContext,OS,OSBmpHandle*,OS*);
extern void WinDisposeBitmap(OSBmpHandle);
extern void WinSetFont (CLEAN_STRING,int,int,OSPictContext,OS,OSPictContext*,OS*);
diff --git a/osbitmap.icl b/osbitmap.icl
index 3074b8f..3a71bae 100644
--- a/osbitmap.icl
+++ b/osbitmap.icl
@@ -43,7 +43,7 @@ osReadBitmap file
= (False,noBitmap,file)
| otherwise
# (hdc, tb) = winCreateScreenHDC OSNewToolbox
- # (hbmp,tb) = winCreateBitmap w data hdc tb
+ # (hbmp,tb) = winCreateBitmap data hdc tb
# tb = winDestroyScreenHDC (hdc,tb)
= (if (tb==OSDummyToolbox) True True,{originalSize=(w,h),reSize=(w,h),bitmapContents=data,bitmapHandle=hbmp},file)
where
diff --git a/pictCCall_12.dcl b/pictCCall_12.dcl
index 1f5aae2..f53d5aa 100644
--- a/pictCCall_12.dcl
+++ b/pictCCall_12.dcl
@@ -78,7 +78,7 @@ winSetFont :: !Fnt !PIC -> PIC
winPrintResizedBitmap :: !(!Int,!Int) !(!Int,!Int) !(!Int,!Int) !{#Char} !PIC -> PIC
winDrawBitmap :: !(!Int,!Int) !(!Int,!Int) !Int !PIC -> PIC
winDrawResizedBitmap :: !(!Int,!Int) !(!Int,!Int) !(!Int,!Int) !Int !PIC -> PIC
-winCreateBitmap :: !Int !{#Char} !HDC !*OSToolbox -> (!Int,!*OSToolbox)
+winCreateBitmap :: !{#Char} !HDC !*OSToolbox -> (!Int,!*OSToolbox)
winInvertPolygon :: !PIC -> PIC
diff --git a/pictCCall_12.icl b/pictCCall_12.icl
index b03661b..dceb7bb 100644
--- a/pictCCall_12.icl
+++ b/pictCCall_12.icl
@@ -59,7 +59,7 @@ winCreateScreenHDC _
= code
{
.inline WinCreateScreenHDC
- ccall WinCreateScreenHDC "I-II"
+ ccall WinCreateScreenHDC "I-pI"
.end
}
@@ -68,7 +68,7 @@ winDestroyScreenHDC _
= code
{
.inline WinDestroyScreenHDC
- ccall WinDestroyScreenHDC "II-I"
+ ccall WinDestroyScreenHDC "pI-I"
.end
}
@@ -78,7 +78,7 @@ winGetPicStringWidth _ _
= code
{
.inline WinGetPicStringWidth
- ccall WinGetPicStringWidth "SII-III"
+ ccall WinGetPicStringWidth "SpI-IpI"
.end
}
@@ -87,7 +87,7 @@ winGetPicCharWidth _ _
= code
{
.inline WinGetPicCharWidth
- ccall WinGetPicCharWidth "III-III"
+ ccall WinGetPicCharWidth "IpI-IpI"
.end
}
// END MW
@@ -115,7 +115,7 @@ winGetPicFontInfo _
= code
{
.inline WinGetPicFontInfo
- ccall WinGetPicFontInfo "II-IIIIII"
+ ccall WinGetPicFontInfo "pI-IIIIpI"
.end
}
@@ -133,7 +133,7 @@ winSetFontStyle _ _
= code
{
.inline WinSetFontStyle
- ccall WinSetFontStyle "III-II"
+ ccall WinSetFontStyle "IpI-pI"
.end
}
@@ -142,7 +142,7 @@ winSetFontSize _ _
= code
{
.inline WinSetFontSize
- ccall WinSetFontSize "III-II"
+ ccall WinSetFontSize "IpI-pI"
.end
}
@@ -151,7 +151,7 @@ winSetFontName _ _
= code
{
.inline WinSetFontName
- ccall WinSetFontName "SII-II"
+ ccall WinSetFontName "SpI-pI"
.end
}
@@ -160,7 +160,7 @@ winSetFont _ _
= code
{
.inline WinSetFont
- ccall WinSetFont "SIIII-II"
+ ccall WinSetFont "SIIpI-pI"
.end
}
@@ -170,7 +170,7 @@ winPrintResizedBitmap _ _ _ _ _
= code
{
.inline WinPrintResizedBitmap
- ccall WinPrintResizedBitmap "IIIIIISII-II"
+ ccall WinPrintResizedBitmap "IIIIIISpI-pI"
.end
}
@@ -180,7 +180,7 @@ winDrawBitmap _ _ _ _
= code
{
.inline WinDrawBitmap
- ccall WinDrawBitmap "IIIIIII-II"
+ ccall WinDrawBitmap "IIIIIpI-pI"
.end
}
@@ -189,16 +189,16 @@ winDrawResizedBitmap _ _ _ _ _
= code
{
.inline WinDrawResizedBitmap
- ccall WinDrawResizedBitmap "IIIIIIIII-II"
+ ccall WinDrawResizedBitmap "IIIIIIIpI-pI"
.end
}
-winCreateBitmap :: !Int !{#Char} !HDC !*OSToolbox -> (!Int,!*OSToolbox)
-winCreateBitmap _ _ _ _
+winCreateBitmap :: !{#Char} !HDC !*OSToolbox -> (!Int,!*OSToolbox)
+winCreateBitmap _ _ _
= code
{
.inline WinCreateBitmap
- ccall WinCreateBitmap "ISII-II"
+ ccall WinCreateBitmap "Spp-pI"
.end
}
@@ -207,7 +207,7 @@ winInvertPolygon _
= code
{
.inline WinInvertPolygon
- ccall WinInvertPolygon "II-II"
+ ccall WinInvertPolygon "pI-pI"
.end
}
@@ -216,7 +216,7 @@ winErasePolygon _
= code
{
.inline WinErasePolygon
- ccall WinErasePolygon "II-II"
+ ccall WinErasePolygon "pI-pI"
.end
}
@@ -225,7 +225,7 @@ winFillPolygon _
= code
{
.inline WinFillPolygon
- ccall WinFillPolygon "II-II"
+ ccall WinFillPolygon "pI-pI"
.end
}
@@ -234,7 +234,7 @@ winDrawPolygon _
= code
{
.inline WinDrawPolygon
- ccall WinDrawPolygon "II-II"
+ ccall WinDrawPolygon "pI-pI"
.end
}
@@ -300,7 +300,7 @@ winInvertWedge _ _ _ _
= code
{
.inline WinInvertWedge
- ccall WinInvertWedge "IIIIIIIIII-II"
+ ccall WinInvertWedge "IIIIIIIIpI-pI"
.end
}
@@ -309,7 +309,7 @@ winEraseWedge _ _ _ _
= code
{
.inline WinEraseWedge
- ccall WinEraseWedge "IIIIIIIIII-II"
+ ccall WinEraseWedge "IIIIIIIIpI-pI"
.end
}
@@ -318,7 +318,7 @@ winFillWedge _ _ _ _
= code
{
.inline WinFillWedge
- ccall WinFillWedge "IIIIIIIIII-II"
+ ccall WinFillWedge "IIIIIIIIpI-pI"
.end
}
@@ -327,7 +327,7 @@ winDrawWedge _ _ _ _
= code
{
.inline WinDrawWedge
- ccall WinDrawWedge "IIIIIIIIII-II"
+ ccall WinDrawWedge "IIIIIIIIpI-pI"
.end
}
@@ -337,7 +337,7 @@ winInvertCircle _ _ _
= code
{
.inline WinInvertCircle
- ccall WinInvertCircle "IIIII-II"
+ ccall WinInvertCircle "IIIpI-pI"
.end
}
@@ -346,7 +346,7 @@ winEraseCircle _ _ _
= code
{
.inline WinEraseCircle
- ccall WinEraseCircle "IIIII-II"
+ ccall WinEraseCircle "IIIpI-pI"
.end
}
@@ -355,7 +355,7 @@ winFillCircle _ _ _
= code
{
.inline WinFillCircle
- ccall WinFillCircle "IIIII-II"
+ ccall WinFillCircle "IIIpI-pI"
.end
}
@@ -364,7 +364,7 @@ winDrawCircle _ _ _
= code
{
.inline WinDrawCircle
- ccall WinDrawCircle "IIIII-II"
+ ccall WinDrawCircle "IIIpI-pI"
.end
}
@@ -374,7 +374,7 @@ winInvertOval _ _
= code
{
.inline WinInvertOval
- ccall WinInvertOval "IIIIII-II"
+ ccall WinInvertOval "IIIIpI-pI"
.end
}
@@ -383,7 +383,7 @@ winEraseOval _ _
= code
{
.inline WinEraseOval
- ccall WinEraseOval "IIIIII-II"
+ ccall WinEraseOval "IIIIpI-pI"
.end
}
@@ -392,7 +392,7 @@ winFillOval _ _
= code
{
.inline WinFillOval
- ccall WinFillOval "IIIIII-II"
+ ccall WinFillOval "IIIIpI-pI"
.end
}
@@ -401,7 +401,7 @@ winDrawOval _ _
= code
{
.inline WinDrawOval
- ccall WinDrawOval "IIIIII-II"
+ ccall WinDrawOval "IIIIpI-pI"
.end
}
@@ -411,7 +411,7 @@ winInvertRoundRectangle _ _ _ _
= code
{
.inline WinInvertRoundRectangle
- ccall WinInvertRoundRectangle "IIIIIIII-II"
+ ccall WinInvertRoundRectangle "IIIIIIpI-pI"
.end
}
@@ -420,7 +420,7 @@ winEraseRoundRectangle _ _ _ _
= code
{
.inline WinEraseRoundRectangle
- ccall WinEraseRoundRectangle "IIIIIIII-II"
+ ccall WinEraseRoundRectangle "IIIIIIpI-pI"
.end
}
@@ -429,7 +429,7 @@ winFillRoundRectangle _ _ _ _
= code
{
.inline WinFillRoundRectangle
- ccall WinFillRoundRectangle "IIIIIIII-II"
+ ccall WinFillRoundRectangle "IIIIIIpI-pI"
.end
}
@@ -438,7 +438,7 @@ winDrawRoundRectangle _ _ _ _
= code
{
.inline WinDrawRoundRectangle
- ccall WinDrawRoundRectangle "IIIIIIII-II"
+ ccall WinDrawRoundRectangle "IIIIIIpI-pI"
.end
}
@@ -448,7 +448,7 @@ winScrollRectangle _ _ _
= code
{
.inline WinScrollRectangle
- ccall WinScrollRectangle "IIIIIIII-IIIIII"
+ ccall WinScrollRectangle "IIIIIIpI-IIIIpI"
.end
}
@@ -457,7 +457,7 @@ winScrollRectangle2 _ _ _
= code
{
.inline WinScrollRectangle2
- ccall WinScrollRectangle2 "IIIIIIII-IIIIII"
+ ccall WinScrollRectangle2 "IIIIIIpI-IIIIpI"
.end
}
@@ -466,7 +466,7 @@ winCopyRectangle _ _ _
= code
{
.inline WinCopyRectangle
- ccall WinCopyRectangle "IIIIIIII-II"
+ ccall WinCopyRectangle "IIIIIIpI-pI"
.end
}
@@ -475,7 +475,7 @@ winCopyRectangleTo _ _ _
= code
{
.inline WinCopyRectangleTo
- ccall WinCopyRectangleTo "IIIIIIII-II"
+ ccall WinCopyRectangleTo "IIIIIIpI-pI"
.end
}