bool amiga_dt_picture_convert(struct content *c) { LOG(("amiga_dt_picture_convert")); union content_msg_data msg_data; int width, height; char title[100]; const uint8 *data; UBYTE *bm_buffer; ULONG size; Object *dto; struct BitMapHeader *bmh; unsigned int bm_flags = BITMAP_NEW; int bm_format = PBPAFMT_RGBA; /* This is only relevant for picture datatypes... */ data = (uint8 *)content__get_source_data(c, &size); if(dto = NewDTObject(NULL, DTA_SourceType, DTST_MEMORY, DTA_SourceAddress, data, DTA_SourceSize, size, DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, TAG_DONE)) { if(GetDTAttrs(dto, PDTA_BitMapHeader, &bmh, TAG_DONE)) { width = (int)bmh->bmh_Width; height = (int)bmh->bmh_Height; } else return false; DisposeDTObject(dto); } else return false; c->width = width; c->height = height; c->size = width * height * 4; image_cache_add(c, NULL, amiga_dt_picture_cache_convert); /* snprintf(title, sizeof(title), "image (%lux%lu, %lu bytes)", width, height, size); content__set_title(c, title); */ content_set_ready(c); content_set_done(c); content_set_status(c, ""); return true; }
int main(int argc, char *argv[]) { if (DataTypesBase=OpenLibrary("datatypes.library",0)) { if (dto=NewDTObject(argv[1],TAG_DONE)) { DoQuery(argv[1]); DisposeDTObject(dto); } CloseLibrary(DataTypesBase); } return 0; }
static struct bitmap *amiga_dt_picture_cache_convert(struct content *c) { LOG(("amiga_dt_picture_cache_convert")); union content_msg_data msg_data; const uint8 *data; UBYTE *bm_buffer; ULONG size; Object *dto; struct bitmap *bitmap; unsigned int bm_flags = BITMAP_NEW; int bm_format = PBPAFMT_RGBA; /* This is only relevant for picture datatypes... */ data = (uint8 *)content__get_source_data(c, &size); if(dto = NewDTObject(NULL, DTA_SourceType, DTST_MEMORY, DTA_SourceAddress, data, DTA_SourceSize, size, DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, TAG_DONE)) { bitmap = bitmap_create(c->width, c->height, bm_flags); if (!bitmap) { msg_data.error = messages_get("NoMemory"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); return NULL; } bm_buffer = bitmap_get_buffer(bitmap); IDoMethod(dto, PDTM_READPIXELARRAY, bm_buffer, bm_format, bitmap_get_rowstride(bitmap), 0, 0, c->width, c->height); DisposeDTObject(dto); } else return NULL; return bitmap; }
Object *amiga_dt_picture_newdtobject(struct amiga_dt_picture_content *adt) { const uint8 *data; ULONG size; if(adt->dto == NULL) { data = (uint8 *)content__get_source_data((struct content *)adt, &size); adt->dto = NewDTObject(NULL, DTA_SourceType, DTST_MEMORY, DTA_SourceAddress, data, DTA_SourceSize, size, DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, TAG_DONE); } return adt->dto; }
VOID ImageDecoderThread () { LONG args[6]; struct RDArgs *readargs; if(readargs = ReadArgs("/A/N,/A/N,/A/N,/A/N,/A/N,/A/F", args, NULL)) { ULONG pageID = *((ULONG *)args[0]); struct ImageList *images = *((struct ImageList **)args[1]); Object *ipc = *((Object **)args[2]); ULONG handle = *((ULONG *)args[3]); struct Screen *scr = *((struct Screen **)args[4]); STRPTR url = (STRPTR)args[5]; Object *dt = NULL; if(dt = NewDTObject(url, DTA_GroupID, GID_PICTURE, PDTA_DestMode, MODE_V43, PDTA_Remap, TRUE, PDTA_FreeSourceBitMap, TRUE, PDTA_Screen, scr, PDTA_UseFriendBitMap, TRUE, TAG_DONE)) { DoMethod(dt, DTM_PROCLAYOUT); } struct IPCMsg ipcmsg(handle, IPCFlg_Unlock); ipcmsg.MethodID = MUIM_IPC_DoMessage; ipcmsg.PageID = pageID; ipcmsg.Images = images; ipcmsg.DTObject = dt; ipcmsg.ImageDecoderThread = FindTask(NULL); if(!DoMethodA(ipc, (Msg)&ipcmsg)) DisposeDTObject(dt); UnlockPubScreen(NULL, scr); } }
/************* * DESCRIPTION: Loads a image with the datatypes. * INPUT: filename name of picture to load * OUTPUT: FALSE if failed *************/ BOOL IMAGE::LoadAsDatatype(char *filename) { struct Library *PictureDTBase; BOOL pic24bit; // TRUE for new 24bit picture.datatype (V43) Object *obj; struct BitMapHeader *bmhd; struct BitMap *bitmap, *tempbitmap; int x,y; SMALL_COLOR *c; UBYTE *colreg, *buffer; int color; ULONG modeid; struct DisplayInfo dispinfo; UBYTE r,g,b; struct RastPort rp, temprp; struct gpBlitPixelArray arg; DataTypesBase = OpenLibrary((unsigned char*)"datatypes.library", 39); if(!DataTypesBase) return FALSE; // try to open the 24bit picture datatype PictureDTBase = OpenLibrary("datatypes/picture.datatype", 43L); if(PictureDTBase) { // we only need the picture.datatype to test the version, therefore // close it now CloseLibrary(PictureDTBase); pic24bit = TRUE; } else pic24bit = FALSE; if(!pic24bit) { // no 24bit version available // get the picture object obj = NewDTObject(filename, DTA_SourceType, DTST_FILE, DTA_GroupID, GID_PICTURE, PDTA_Remap, FALSE, TAG_DONE); if(!obj) { CloseLibrary(DataTypesBase); return FALSE; } } else { // get the picture object obj = NewDTObject(filename, DTA_SourceType, DTST_FILE, DTA_GroupID, GID_PICTURE, PDTA_Remap, FALSE, PDTA_DestMode, MODE_V43, TAG_DONE); if(!obj) { CloseLibrary(DataTypesBase); return FALSE; } } // get the bitmap header if(GetDTAttrs(obj, PDTA_ColorRegisters, &colreg, PDTA_BitMap, &bitmap, PDTA_ModeID, &modeid, PDTA_BitMapHeader, &bmhd, TAG_DONE) != 4) { DisposeDTObject(obj); CloseLibrary(DataTypesBase); return FALSE; } if(!bmhd || !bitmap) { DisposeDTObject(obj); CloseLibrary(DataTypesBase); return FALSE; } width = bmhd->bmh_Width; height = bmhd->bmh_Height; if(!GetDisplayInfoData(NULL, (UBYTE*)&dispinfo, sizeof(struct DisplayInfo), DTAG_DISP, modeid)) { DisposeDTObject(obj); CloseLibrary(DataTypesBase); return FALSE; } colormap = (SMALL_COLOR*)malloc(sizeof(SMALL_COLOR)*width*height); if(!colormap) { DisposeDTObject(obj); CloseLibrary(DataTypesBase); return FALSE; } c = colormap; if((bmhd->bmh_Depth > 8) && pic24bit) { // true color picture buffer = (UBYTE*)AllocVec(3*width, MEMF_PUBLIC); if(!buffer) { DisposeDTObject(obj); CloseLibrary(DataTypesBase); return FALSE; } for(y=0; y<height; y++) { arg.MethodID = DTM_READPIXELARRAY; arg.PixelArray = buffer; arg.PixelArrayMode = RECTFMT_RGB; arg.PixelArrayMod = 3*width; arg.LeftEdge = 0; arg.TopEdge = y; arg.Width = width; arg.Height = 1; #ifdef __PPC__ ppc_DoMethodA(obj, (Msg)&arg); #else DoMethodA(obj, (Msg)&arg); #endif for(x=0; x<width; x++) { c->r = buffer[x*3]; c->g = buffer[x*3+1]; c->b = buffer[x*3+2]; c++; } } FreeVec(buffer); } else { // normal picture // planar to chunky conversion InitRastPort(&rp); rp.BitMap = bitmap; tempbitmap = AllocBitMap(width, 1, bmhd->bmh_Depth, BMF_CLEAR, NULL); if(!tempbitmap) { DisposeDTObject(obj); CloseLibrary(DataTypesBase); return FALSE; } InitRastPort(&temprp); temprp.BitMap = tempbitmap; buffer = (UBYTE*)AllocVec((width+15)&(~15), MEMF_PUBLIC); if(!buffer) { FreeBitMap(tempbitmap); DisposeDTObject(obj); CloseLibrary(DataTypesBase); return FALSE; } if(dispinfo.PropertyFlags & DIPF_IS_HAM) { // Simulate HAM mode if(bmhd->bmh_Depth == 8) { // Super HAM for(y=0; y<height; y++) { r = g = b = 0; ReadPixelLine8(&rp, 0, y, width, buffer, &temprp); for(x=0; x<width; x++) { color = buffer[x]; switch(color & 0xc0) { case 0x00: // Take it from color registers color *= 3; r = colreg[color]; g = colreg[color+1]; b = colreg[color+2]; break; case 0x40: // modify blue b = color << 2; break; case 0x80: // modify red r = color << 2; break; case 0xc0: // modify green g = color << 2; break; } c->r = r; c->g = g; c->b = b; c++; } } } else { // Normal HAM for(y=0; y<height; y++) { r = g = b = 0; ReadPixelLine8(&rp, 0, y, width, buffer, &temprp); for(x=0; x<width; x++) { color = buffer[x]; switch(color & 0x30) { case 0x00: // Take it from color registers color *= 3; r = colreg[color]; g = colreg[color+1]; b = colreg[color+2]; break; case 0x40: // modify blue b = color << 4; break; case 0x80: // modify red r = color << 4; break; case 0xc0: // modify green g = color << 4; break; } c->r = r; c->g = g; c->b = b; c++; } } } } else { for(y=0; y<height; y++) { ReadPixelLine8(&rp, 0, y, width, buffer, &temprp); for(x=0; x<width; x++) { color = buffer[x]; color *= 3; c->r = colreg[color]; c->g = colreg[color+1]; c->b = colreg[color+2]; c++; } } } FreeVec(buffer); FreeBitMap(tempbitmap); } DisposeDTObject(obj); CloseLibrary(DataTypesBase); return TRUE; }
// Load a backfill pattern; pattern must be locked exclusively void GetPattern(PatternData *pattern,struct Screen *screen,ULONG border_col) { // Initially make invalid pattern->valid=FALSE; pattern->border_pen=0; // Set screen pointer pattern->screen=screen; // Check for invalid data if (!pattern->data) { // Update border pen GetPatternBorder(pattern,screen,border_col); return; } // Bitmap pattern? if (pattern->prefs.wbp_Flags&WBPF_PATTERN) { UWORD *ptr,*planes[MAXDEPTH]; short num,row,col,pen; // Get plane pointers for (num=0;num<pattern->prefs.wbp_Depth;num++) { planes[num]=((UWORD *)pattern->data)+(PAT_HEIGHT*num); } pattern->fill_plane_key=0; // Clear fill initially for (num=0,ptr=pattern->fill[0];num<128;num++,ptr++) *ptr=0; // Under 37 use fill pattern as supplied if (((struct Library *)GfxBase)->lib_Version<39) { for (num=0;num<pattern->prefs.wbp_Depth;num++) { CopyMem( (char *)planes[num], (char *)pattern->fill[num], PAT_HEIGHT*sizeof(UWORD)); } pattern->fill_plane_key=pattern->prefs.wbp_Depth; } // Otherwise, we need to remap else { // Go through pattern rows for (row=0;row<PAT_HEIGHT;row++) { // Go through bits for (col=0;col<PAT_WIDTH;col++) { // Clear pen pen=0; // Calculate pixel colour for (num=0;num<pattern->prefs.wbp_Depth;num++) { // Is bit set in this bitplane? if (planes[num][row]&(1<<col)) pen|=(1<<num); } // Pixel set? if (pen) { // Map pens 4-7 to top four colours if (pen>=4 && screen->RastPort.BitMap->Depth<=8) { pen=(1<<screen->RastPort.BitMap->Depth)-(8-pen); } // Remap for (num=0;num<8;num++) { // Want this bit? if (pen&(1<<num)) { // Set bit pattern->fill[num][row]|=1<<col; if (num>=pattern->fill_plane_key) pattern->fill_plane_key=num+1; } } } } } } // Any data? if (pattern->fill_plane_key>0) { short depth; // Get depth for bitmap if (((struct Library *)GfxBase)->lib_Version>=39) depth=GetBitMapAttr(screen->RastPort.BitMap,BMA_DEPTH); else depth=screen->RastPort.BitMap->Depth; // Check its not too deep if (depth>8) depth=8; // Allocate bitmap for pattern if ((pattern->pattern_bitmap= NewBitMap( PATTILE_SIZE, PATTILE_SIZE, depth, BMF_CLEAR, 0))) { struct RastPort rp; struct BitMap *bitmap; // Initialise dummy rastport InitRastPort(&rp); rp.BitMap=pattern->pattern_bitmap; // Set fill pattern SetAfPt(&rp,pattern->fill[0],-4); // Fill bitmap SetRast(&rp,0); RectFill(&rp,0,0,PATTILE_SIZE-1,PATTILE_SIZE-1); // Is the screen a non-standard bitmap? if (((struct Library *)GfxBase)->lib_Version>=39 && !(GetBitMapAttr(screen->RastPort.BitMap,BMA_FLAGS)&BMF_STANDARD)) { // Try and allocate friend bitmap if ((bitmap= NewBitMap( PATTILE_SIZE, PATTILE_SIZE, depth, BMF_CLEAR, screen->RastPort.BitMap))) { // Copy to friend bitmap BltBitMap( pattern->pattern_bitmap,0,0, bitmap,0,0, PATTILE_SIZE,PATTILE_SIZE, 0xc0,0xff,0); // Free original bitmap DisposeBitMap(pattern->pattern_bitmap); // Use new bitmap pointer pattern->pattern_bitmap=bitmap; } } // Get bitmap pointer pattern->bitmap=pattern->pattern_bitmap; // Get pattern size pattern->width=PATTILE_SIZE; pattern->height=PATTILE_SIZE; } } } // Picture; must have datatypes else if (DataTypesBase) { short len; BOOL remap=1; long precision=PRECISION_IMAGE; char name[256]; long ver=0; struct Library *pdt; #ifdef PATCH_OK APTR patchhandle=0; #endif // Check picture datatype version if ((pdt=OpenLibrary("sys:classes/datatypes/picture.datatype",0)) || (pdt=OpenLibrary("picture.datatype",0))) { // Get version ver=pdt->lib_Version; CloseLibrary(pdt); } // No remap? if ((len=strlen(pattern->data))>8 && stricmp(pattern->data+len-8,".noremap")==0) remap=0; // Precision? if (len>6 && stricmp(pattern->data+len-6,".exact")==0) precision=PRECISION_EXACT; // Specified in prefs? else if (pattern->precision) { if (pattern->precision==-1) remap=0; else if (pattern->precision==1) precision=PRECISION_ICON; else if (pattern->precision==2) precision=PRECISION_GUI; else if (pattern->precision==3) precision=PRECISION_EXACT; } #ifdef PATCH_OK // If we've got v43 of the datatype, we don't need the fastram patch if (ver<43) { // Add this task to the patchlist for allocbitmap patchhandle=AddAllocBitmapPatch(FindTask(0),screen); } #endif // Turn back on requesters ((struct Process *)FindTask(0))->pr_WindowPtr=GUI->window; // Check for random pictures, and then load picture if (pattern_check_random(pattern,name) && (pattern->object= NewDTObject(name, DTA_GroupID,GID_PICTURE, PDTA_Screen,screen, PDTA_FreeSourceBitMap,TRUE, (ver>42)?PDTA_DestMode:TAG_IGNORE,MODE_V43, (ver>42)?PDTA_UseFriendBitMap:TAG_IGNORE,TRUE, TAG_END))) { struct BitMapHeader *header; struct BitMap *bitmap; D_S(struct FileInfoBlock, fib) // Get file information if (GetFileInfo(name,fib) && strnicmp(fib->fib_Comment,"dopus ",6)==0) { char *args=fib->fib_Comment+6; short val; rexx_skip_space(&args); while ((val=rexx_match_keyword(&args,background_key,0))!=-1) { // Tile/center/stretch if (val==3) pattern->flags&=~(PATF_CENTER|PATF_STRETCH); else if (val==4) { pattern->flags|=PATF_CENTER; pattern->flags&=~PATF_STRETCH; } else if (val==5 && pattern->prefs.wbp_Which==0) { pattern->flags|=PATF_STRETCH; pattern->flags&=~PATF_CENTER; } // Precision else if (val==6) { // Get precision rexx_skip_space(&args); if ((val=rexx_match_keyword(&args,precision_key,0))>-1) { if (val==0) remap=0; else if (val==1) precision=PRECISION_GUI; else if (val==2) precision=PRECISION_ICON; else if (val==3) precision=PRECISION_IMAGE; else if (val==4) precision=PRECISION_EXACT; } } // Border else if (val==8) { // Off? rexx_skip_space(&args); if (rexx_match_keyword(&args,on_off_strings2,0)==0) border_col&=~ENVBF_USE_COLOUR; else { border_col=ENVBF_USE_COLOUR; border_col|=Atoh(args,-1)<<8; } } } } // Layout picture (should check for success) SetDTAttrs(pattern->object,0,0, OBP_Precision,precision, PDTA_Remap,remap, TAG_END); DoMethod(pattern->object,DTM_PROCLAYOUT,0,1); // Get bitmap pointer and header GetDTAttrs(pattern->object, PDTA_BitMap,&bitmap, PDTA_DestBitMap,&pattern->bitmap, PDTA_BitMapHeader,&header, TAG_END); // No dest bitmap? if (!pattern->bitmap) pattern->bitmap=bitmap; // Valid bitmap? if (pattern->bitmap) { // Get width and height pattern->width=header->bmh_Width; pattern->height=header->bmh_Height; } } // Turn off requesters ((struct Process *)FindTask(0))->pr_WindowPtr=(APTR)-1; #ifdef PATCH_OK // Remove this task from the patchlist for allocbitmap if (patchhandle) RemAllocBitmapPatch(patchhandle); #endif // Got bitmap? if (pattern->bitmap) { // Stretch? if (pattern->flags&PATF_STRETCH) { // Not the size of the screen? if (pattern->width!=screen->Width || pattern->height!=screen->Height) { // Allocate a bitmap for the stretched picture if ((pattern->pattern_bitmap= NewBitMap( screen->Width, screen->Height, GetBitMapAttr(pattern->bitmap,BMA_DEPTH), BMF_CLEAR, screen->RastPort.BitMap))) { struct BitScaleArgs scale; // Scale bitmap scale.bsa_SrcX=0; scale.bsa_SrcY=0; scale.bsa_SrcWidth=pattern->width; scale.bsa_SrcHeight=pattern->height; scale.bsa_DestX=0; scale.bsa_DestY=0; scale.bsa_DestWidth=screen->Width; scale.bsa_DestHeight=screen->Height; scale.bsa_XSrcFactor=scale.bsa_SrcWidth; scale.bsa_XDestFactor=scale.bsa_DestWidth; scale.bsa_YSrcFactor=scale.bsa_SrcHeight; scale.bsa_YDestFactor=scale.bsa_DestHeight; scale.bsa_SrcBitMap=pattern->bitmap; scale.bsa_DestBitMap=pattern->pattern_bitmap; scale.bsa_Flags=0; BitMapScale(&scale); // Get pointer to scaled bitmap pattern->bitmap=pattern->pattern_bitmap; pattern->width=screen->Width; pattern->height=screen->Height; } } } } // Update border pen GetPatternBorder(pattern,screen,border_col); } // Pattern ok now pattern->valid=TRUE; }
///ImageBackFill__MUIM_IconWindow_BackFill_ProcessBackground() IPTR ImageBackFill__MUIM_IconWindow_BackFill_ProcessBackground ( Class *CLASS, Object *self, struct MUIP_IconWindow_BackFill_ProcessBackground *message ) { LONG Depth = 0; Object *_IconWindows_PrefsObj = NULL, *_IconWindows_WindowObj = NULL; Object *_IconWindows_IconListObj = NULL; BOOL options_changed = FALSE; IPTR prefs_processing = 0; IPTR BackGround_Attrib = 0, BackGround_Base = 0, BackGround_RenderMode = 0, BackGround_TileMode = 0, BackGround_XOffset = 0, BackGround_YOffset = 0; struct BackFillInfo *this_BFI =(struct BackFillInfo *) message->BackFill_Data; UBYTE *this_bgtype; char *this_ImageName; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground()\n")); GET(_app(self), MUIA_Wanderer_Prefs, &_IconWindows_PrefsObj); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: PrefsObj @ %x\n", _IconWindows_PrefsObj)); GET(self, MUIA_IconWindow_Window, &_IconWindows_WindowObj); GET(self, MUIA_IconWindow_IconList, &_IconWindows_IconListObj); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: MUIA_IconWindow_Window = %x\n", _IconWindows_WindowObj)); if ((_IconWindows_PrefsObj == NULL) || (_IconWindows_WindowObj == NULL) || (_IconWindows_IconListObj == NULL)) return FALSE; GET(_IconWindows_PrefsObj, MUIA_WandererPrefs_Processing, &prefs_processing); #if defined(DEBUG) if (prefs_processing) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Wanderer Prefs (re)loading detected\n")); } #endif GET(_IconWindows_WindowObj, MUIA_IconWindow_BackgroundAttrib, &BackGround_Attrib); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background Attrib = '%s'\n", BackGround_Attrib)); if (BackGround_Attrib == (IPTR) NULL) return FALSE; if ((BackGround_Base = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_Background)) == -1) return FALSE; if ((BackGround_RenderMode = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGRenderMode)) == -1) BackGround_RenderMode = IconWindowExt_ImageBackFill_RenderMode_Tiled; this_bgtype = (UBYTE *)BackGround_Base; this_ImageName = (char *)(BackGround_Base + 2); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: BackFillInfo @ %x\n", this_BFI)); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background '%s', mode %d\n", BackGround_Base, BackGround_RenderMode)); if ((this_bgtype[0] - 48) != 5) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background is NOT an image - letting our windoclass handle it ..\n")); goto pb_cleanup_buffer; } GET(self, MUIA_Window_Screen, &this_BFI->bfi_Screen); GET(_IconWindows_IconListObj, MUIA_IconList_BufferRastport, &this_BFI->bfi_RastPort); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Wanderers Screen @ %x, Using RastPort @ %x\n", this_BFI->bfi_Screen, this_BFI->bfi_RastPort)); if (this_BFI->bfi_Source) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: BackFillInfo has existing source record @ %x\n", this_BFI->bfi_Source)); if ((strcmp(this_BFI->bfi_Source->bfsir_SourceImage, this_ImageName) == 0) && (this_BFI->bfi_Source->bfsir_BackGroundRenderMode == BackGround_RenderMode)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: existing BackFillInfo Using the same background / mode\n")); goto check_imagebuffer; } else { if (this_BFI->bfi_Buffer) { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } ImageBackFill_CloseSourceRecord(this_BFI->bfi_Source); this_BFI->bfi_Source = NULL; } } if (!(this_BFI->bfi_Source)) this_BFI->bfi_Source = ImageBackFill_FindSourceRecord(this_ImageName, BackGround_RenderMode); if (!(this_BFI->bfi_Source)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Creating NEW ImageSource Record\n")); if (!(this_BFI->bfi_Source = AllocMem(sizeof(struct BackFillSourceImageRecord), MEMF_CLEAR|MEMF_PUBLIC))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Couldnt allocate enough mem for source record!\n")); return FALSE; } if (!(this_BFI->bfi_Source->bfsir_SourceImage = AllocVec(strlen(this_ImageName) +1, MEMF_CLEAR|MEMF_PUBLIC))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Couldnt allocate enough mem for source image name store\n")); FreeMem(this_BFI->bfi_Source, sizeof(struct BackFillSourceImageRecord)); return FALSE; } strcpy(this_BFI->bfi_Source->bfsir_SourceImage, this_ImageName); if ((this_BFI->bfi_Source->bfsir_DTPictureObject = NewDTObject(this_BFI->bfi_Source->bfsir_SourceImage, DTA_SourceType, DTST_FILE, DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, PDTA_Remap, TRUE, PDTA_Screen, this_BFI->bfi_Screen, PDTA_FreeSourceBitMap, TRUE, OBP_Precision, PRECISION_IMAGE, TAG_DONE))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Opened Datatype Object @ %x for image '%s'\n", this_BFI->bfi_Source->bfsir_DTPictureObject, this_BFI->bfi_Source->bfsir_SourceImage)); if (DoMethod(this_BFI->bfi_Source->bfsir_DTPictureObject, DTM_PROCLAYOUT, NULL, 1)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Caused Datatype Object LAYOUT\n")); GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_BitMapHeader, &this_BFI->bfi_Source->bfsir_DTBitMapHeader, TAG_DONE); GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_DestBitMap, &this_BFI->bfi_Source->bfsir_DTBitMap, TAG_DONE); if (!this_BFI->bfi_Source->bfsir_DTBitMap) GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_BitMap, &this_BFI->bfi_Source->bfsir_DTBitMap, TAG_DONE); if (this_BFI->bfi_Source->bfsir_DTBitMap) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Datatype Object BitMap @ %x\n", this_BFI->bfi_Source->bfsir_DTBitMap)); if ((this_BFI->bfi_Source->bfsir_DTRastPort = CreateRastPort())) { this_BFI->bfi_Source->bfsir_DTRastPort->BitMap = this_BFI->bfi_Source->bfsir_DTBitMap; this_BFI->bfi_Source->bfsir_BackGroundRenderMode = BackGround_RenderMode; this_BFI->bfi_Source->bfsir_OpenerCount = 0x01; NewList(&this_BFI->bfi_Source->bfsir_Buffers); AddTail(&image_backfill_images, &this_BFI->bfi_Source->bfsir_Node); goto check_imagebuffer; } } /* Failed to obtain datatype object's BM */ } /* Failed to Layout datatype object */ } /* Failed to open datatype object */ #if defined(DEBUG) if (!this_BFI->bfi_Source->bfsir_DTRastPort) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource RastPort\n")); } #endif if (this_BFI->bfi_Source->bfsir_DTBitMap) { FreeBitMap(this_BFI->bfi_Source->bfsir_DTBitMap); this_BFI->bfi_Source->bfsir_DTBitMap = NULL; } #if defined(DEBUG) else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource BitMap\n")); } #endif if (this_BFI->bfi_Source->bfsir_DTPictureObject) { DisposeDTObject(this_BFI->bfi_Source->bfsir_DTPictureObject); this_BFI->bfi_Source->bfsir_DTPictureObject = NULL; } #if defined(DEBUG) else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource Datatype Object\n")); } #endif D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource Record\n")); if (this_BFI->bfi_Source->bfsir_SourceImage) FreeVec(this_BFI->bfi_Source->bfsir_SourceImage); FreeMem(this_BFI->bfi_Source, sizeof(struct BackFillSourceImageRecord)); this_BFI->bfi_Source = NULL; return FALSE; } else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Using existing ImageSource Record\n")); this_BFI->bfi_Source->bfsir_OpenerCount += 1; } check_imagebuffer: Depth = GetBitMapAttr(this_BFI->bfi_Source->bfsir_DTBitMap, BMA_DEPTH); this_BFI->bfi_CopyWidth = this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width; this_BFI->bfi_CopyHeight = this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height; switch (BackGround_RenderMode) { case IconWindowExt_ImageBackFill_RenderMode_Scale: { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED mode\n")); this_BFI->bfi_Options.bfo_TileMode = IconWindowExt_ImageBackFill_TileMode_Fixed; SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, TRUE); SET(_IconWindows_IconListObj, MUIA_IconListview_ScaledBackground, TRUE); if ((BOOL)XGET(self, MUIA_IconWindow_IsRoot)) { struct BackFillSourceImageBuffer *this_Buffer; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Root Window = TRUE!\n")); this_BFI->bfi_CopyWidth = GetBitMapAttr(this_BFI->bfi_Screen->RastPort.BitMap, BMA_WIDTH); this_BFI->bfi_CopyHeight = GetBitMapAttr(this_BFI->bfi_Screen->RastPort.BitMap, BMA_HEIGHT); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Base Dimensions (%d x %d)\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); if (!((BOOL)XGET(self, MUIA_IconWindow_IsBackdrop))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Adjusting for window border Dimensions ..\n")); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - WBorTop %d, WBorLeft %d, WBorRight %d, WBorBottom %d\n", this_BFI->bfi_Screen->WBorTop, this_BFI->bfi_Screen->WBorLeft, this_BFI->bfi_Screen->WBorRight, this_BFI->bfi_Screen->WBorBottom)); this_BFI->bfi_CopyWidth -= (this_BFI->bfi_Screen->WBorLeft + this_BFI->bfi_Screen->WBorRight); this_BFI->bfi_CopyHeight -= (this_BFI->bfi_Screen->WBorTop + this_BFI->bfi_Screen->WBorBottom);; } this_BFI->bfi_CopyHeight -= (this_BFI->bfi_Screen->BarHeight + 1); this_Buffer = NULL; if (this_BFI->bfi_Buffer) { if ((this_BFI->bfi_Buffer->bfsib_BitMapWidth == this_BFI->bfi_CopyWidth) && (this_BFI->bfi_Buffer->bfsib_BitMapHeight == this_BFI->bfi_CopyHeight)) { goto pb_backfillsetup_complete; } else { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } } if (!(this_Buffer = ImageBackFill_FindBufferRecord(this_BFI->bfi_Source, this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight))) { this_Buffer = AllocMem(sizeof(struct BackFillSourceImageBuffer), MEMF_CLEAR|MEMF_PUBLIC); this_Buffer->bfsib_BitMapWidth = this_BFI->bfi_CopyWidth; this_Buffer->bfsib_BitMapHeight = this_BFI->bfi_CopyHeight; if (!(this_Buffer->bfsib_BitMapRastPort = CreateRastPort())) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Failed to create RastPort for BackFill BitMap\n")); break; } if ((this_Buffer->bfsib_BitMap = AllocBitMap(this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight, Depth, Depth == 8 ? BMF_MINPLANES : 0L, this_BFI->bfi_Screen->RastPort.BitMap))) { struct Rectangle CopyBounds; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Scale Dimensions (%d x %d)\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); this_Buffer->bfsib_BitMapRastPort->BitMap = this_Buffer->bfsib_BitMap; this_BFI->bfi_Buffer = this_Buffer; CopyBounds.MinX = 0; CopyBounds.MinY = 0; CopyBounds.MaxX = this_BFI->bfi_CopyWidth - 1; CopyBounds.MaxY = this_BFI->bfi_CopyHeight - 1; ImageBackFill_CopyScaledBitMap(this_BFI->bfi_Source->bfsir_DTRastPort, 0, 0, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height, this_Buffer->bfsib_BitMapRastPort, &CopyBounds, &CopyBounds, blit_MODE_Blit); this_Buffer->bfsib_OpenerCount = 0x01; AddTail(&this_BFI->bfi_Source->bfsir_Buffers, &this_Buffer->bfsib_Node); goto pb_backfillsetup_complete; } break; } else { this_BFI->bfi_Buffer = this_Buffer; this_Buffer->bfsib_OpenerCount += 1; goto pb_backfillsetup_complete; } } // We arent the "ROOT" (desktop) window so only tile ... D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Drawer window scaling unsupported ...\n")); } default: { struct BackFillSourceImageBuffer *this_Buffer; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: TILED mode\n")); if ((BackGround_TileMode = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGTileMode)) == -1) BackGround_TileMode = IconWindowExt_ImageBackFill_TileMode_Float; if ((BackGround_XOffset = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGXOffset)) == -1) BackGround_XOffset = 0; if ((BackGround_YOffset = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGYOffset)) == -1) this_BFI->bfi_Options.bfo_OffsetY = 0; if (this_BFI->bfi_Options.bfo_TileMode != BackGround_TileMode) { this_BFI->bfi_Options.bfo_TileMode = BackGround_TileMode; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_OffsetX != BackGround_XOffset) { this_BFI->bfi_Options.bfo_OffsetX = BackGround_XOffset; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_OffsetY != BackGround_YOffset) { this_BFI->bfi_Options.bfo_OffsetY = BackGround_YOffset; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_TileMode == IconWindowExt_ImageBackFill_TileMode_Float) SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, FALSE); else SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, TRUE); SET(_IconWindows_IconListObj, MUIA_IconListview_ScaledBackground, FALSE); this_Buffer = NULL; if (this_BFI->bfi_Buffer) { if ((this_BFI->bfi_Buffer->bfsib_BitMapWidth == this_BFI->bfi_CopyWidth) && (this_BFI->bfi_Buffer->bfsib_BitMapHeight == this_BFI->bfi_CopyHeight)) { goto pb_backfillsetup_complete; } else { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } } D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Dimensions Width %d, Height %d\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); if (!(this_Buffer = ImageBackFill_FindBufferRecord(this_BFI->bfi_Source, this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight))) { this_Buffer = AllocMem(sizeof(struct BackFillSourceImageBuffer), MEMF_CLEAR|MEMF_PUBLIC); this_Buffer->bfsib_BitMapWidth = this_BFI->bfi_CopyWidth; this_Buffer->bfsib_BitMapHeight = this_BFI->bfi_CopyHeight; if ((this_Buffer->bfsib_BitMap = AllocBitMap(this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight, Depth, Depth == 8 ? BMF_MINPLANES : 0L, this_BFI->bfi_Screen->RastPort.BitMap))) { struct Rectangle CopyBounds; if (!(this_Buffer->bfsib_BitMapRastPort = CreateRastPort())) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: TILED - Failed to create RastPort for BackFill BitMap\n")); break; } this_Buffer->bfsib_BitMapRastPort->BitMap = this_Buffer->bfsib_BitMap; this_BFI->bfi_Buffer = this_Buffer; CopyBounds.MinX = 0; CopyBounds.MinY = 0; CopyBounds.MaxX = this_BFI->bfi_CopyWidth - 1; CopyBounds.MaxY = this_BFI->bfi_CopyHeight - 1; ImageBackFill_CopyTiledBitMap(this_BFI->bfi_Source->bfsir_DTRastPort, 0, 0, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height, this_BFI->bfi_Buffer->bfsib_BitMapRastPort, &CopyBounds, &CopyBounds, blit_MODE_Blit); this_Buffer->bfsib_OpenerCount = 0x01; AddTail(&this_BFI->bfi_Source->bfsir_Buffers, &this_BFI->bfi_Buffer->bfsib_Node); goto pb_backfillsetup_complete; } break; } else { this_BFI->bfi_Buffer = this_Buffer; this_Buffer->bfsib_OpenerCount += 1; goto pb_backfillsetup_complete; } } } D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create image datatype object\n")); return FALSE; pb_cleanup_buffer: if (this_BFI->bfi_Buffer) { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } pb_cleanup_source: if (this_BFI->bfi_Source) { ImageBackFill_CloseSourceRecord(this_BFI->bfi_Source); this_BFI->bfi_Source = NULL; } return FALSE; pb_backfillsetup_complete: if ((prefs_processing) && (options_changed)) SET(self, MUIA_IconWindow_Changed, TRUE); return TRUE; }