aboutsummaryrefslogtreecommitdiff
path: root/Linux_C_12
diff options
context:
space:
mode:
authorCamil Staps2015-08-24 01:28:28 +0200
committerCamil Staps2015-08-24 01:28:28 +0200
commit447c0f0d09cd8a5555ee8f4b199f0de7013ed304 (patch)
tree9e35a9347e139c55c325954bf252916f9576a4af /Linux_C_12
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).
Diffstat (limited to 'Linux_C_12')
-rw-r--r--Linux_C_12/cpicture_121.c25
-rw-r--r--Linux_C_12/cpicture_121.h2
2 files changed, 18 insertions, 9 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*);