From 08d0c1682250763c0f8300e54bfa877345edd5fb Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 16 May 2009 17:04:28 +0000 Subject: Copy and save images as IFF ILBM attempt 2. Copy now works, saving just creates an empty file - probably something wrong with my DTM_WRITE call. svn path=/trunk/netsurf/; revision=7517 --- amiga/clipboard.c | 74 ++++++------------------------------------------------- 1 file changed, 7 insertions(+), 67 deletions(-) (limited to 'amiga/clipboard.c') diff --git a/amiga/clipboard.c b/amiga/clipboard.c index 5afc2d2fe..94457f40a 100755 --- a/amiga/clipboard.c +++ b/amiga/clipboard.c @@ -28,9 +28,8 @@ #include "utils/utf8.h" #include "desktop/selection.h" #include -#include -#include -#include "utils/messages.h" +#include +#include "amiga/bitmap.h" #ifndef ID_AUTH #define ID_AUTH MAKE_ID('A','U','T','H') @@ -245,72 +244,13 @@ bool ami_easy_clipboard(char *text) return false; } -bool ami_easy_clipboard_bitmap(struct bitmap *bitmap,struct IFFHandle *ih, - char *url,char *name) +bool ami_easy_clipboard_bitmap(struct bitmap *bitmap) { - struct BitMapHeader *bmhd; - uint32 bmdatasize = bitmap_get_width(bitmap) * - bitmap_get_height(bitmap) * - bitmap_get_bpp(bitmap); + Object *dto = NULL; - if(!ih) ih = iffh; - - if(!(OpenIFF(ih,IFFF_WRITE))) + if(dto = ami_datatype_object_from_bitmap(bitmap)) { - if(!(PushChunk(ih,ID_ILBM,ID_FORM,IFFSIZE_UNKNOWN))) - { - if(bmhd = AllocVec(sizeof(struct BitMapHeader),MEMF_CLEAR | MEMF_PRIVATE)) - { - if(!(PushChunk(ih,0,ID_BMHD,sizeof(struct BitMapHeader)))) - { - bmhd->bmh_Width = (UWORD)bitmap_get_width(bitmap); - bmhd->bmh_Height = (UWORD)bitmap_get_height(bitmap); - bmhd->bmh_Depth = (UBYTE)bitmap_get_bpp(bitmap) * 8; - bmhd->bmh_Masking = mskHasAlpha; - WriteChunkBytes(ih,bmhd,sizeof(struct BitMapHeader)); - } - PopChunk(ih); - FreeVec(bmhd); - } - - if(!(PushChunk(ih,0,ID_AUTH,IFFSIZE_UNKNOWN))) - { - STRPTR ilbm_auth = ASPrintf("%s %s",messages_get("NetSurf"),netsurf_version); - WriteChunkBytes(ih,ilbm_auth,strlen(ilbm_auth)); - FreeVec(ilbm_auth); - } - PopChunk(ih); - - if(!(PushChunk(ih,0,ID_NAME,IFFSIZE_UNKNOWN))) - { - WriteChunkBytes(ih,name,strlen(name)); - } - PopChunk(ih); - - if(!(PushChunk(ih,0,ID_ANNO,IFFSIZE_UNKNOWN))) - { - WriteChunkBytes(ih,url,strlen(url)); - } - PopChunk(ih); - - if(!(PushChunk(ih,0,ID_BODY,bmdatasize))) - { - WriteChunkBytes(ih,bitmap_get_buffer(bitmap),bmdatasize); - PopChunk(ih); - CloseIFF(ih); - return true; - } - else - { - PopChunk(ih); - } - } - else - { - PopChunk(ih); - } - CloseIFF(ih); + DoDTMethod(dto,NULL,NULL,DTM_COPY,NULL); + DisposeDTObject(dto); } - - return false; } -- cgit v1.2.3