struct RastPort *RenderMessage::ObtainDoubleBuffer (ULONG width, ULONG height) { if(BufferRP) { if(width > BufferWidth || height > BufferHeight) { WaitBlit(); FreeBitMap(BufferRP->BitMap); BufferWidth = MAX(BufferWidth, width); BufferHeight = MAX(BufferHeight, height); BufferRP->BitMap = AllocBitMap(BufferWidth, BufferHeight, GetBitMapAttr(RPort->BitMap, BMA_DEPTH), BMF_MINPLANES, RPort->BitMap); } } else { BufferRP = new (std::nothrow) struct RastPort[1]; if (!BufferRP) return NULL; InitRastPort(BufferRP); BufferRP->BitMap = AllocBitMap(width, height, GetBitMapAttr(RPort->BitMap, BMA_DEPTH), BMF_MINPLANES, RPort->BitMap); BufferWidth = width; BufferHeight = height; } return(BufferRP->BitMap ? BufferRP : NULL); }
bool InitDisplay(int width, int height, int depth) { if (!Display) { size_t i, j; Display = NewRecord(DisplayT); for (i = 0; i < 2; i++) Display->Bitmap[i] = AllocBitMap(width, height, depth, BMF_DISPLAYABLE|BMF_CLEAR, NULL); Display->Palette = NewRecord(ScreenPaletteT); Display->Palette->Count = 256; for (i = 0, j = 0; i < 256; i++) { Display->Palette->Colors[j++] = i << 24; Display->Palette->Colors[j++] = i << 24; Display->Palette->Colors[j++] = i << 24; } ScreenTags[0].ti_Data = width; ScreenTags[1].ti_Data = height; ScreenTags[2].ti_Data = depth; ScreenTags[3].ti_Data = (ULONG)Display->Bitmap[0]; ScreenTags[4].ti_Data = (ULONG)Display->Palette; if ((Display->Screen = OpenScreenTagList(0L, ScreenTags))) { return TRUE; } else { KillDisplay(); } } return FALSE; }
void createbehindlayer(void) { int x0,y0,x1,y1; int i; char c, s; LONG flags = 0; struct BitMap * sb = NULL; for (i = 0; i < 10; i++) { if (layers[i] == NULL) break; } if (i < 10) { printf("Backdroplayer [y/N]: "); scanf("%c", &c); printf("SuperBitMap [y/N]: "); scanf("%c", &s); printf("x0: "); scanf("%d", &x0); printf("y0: "); scanf("%d", &y0); printf("x1: "); scanf("%d", &x1); printf("y1: "); scanf("%d", &y1); if (c=='y' || c=='Y') { printf("Generating a backdrop layer.\n"); flags |= LAYERBACKDROP; } if (s=='y' || s=='Y') { printf("Generating a superbitmap layer.\n"); flags |= LAYERSUPER; sb = AllocBitMap(x1-x0+1,y1-y0+1,1,BMF_CLEAR,NULL); } flags |= LAYERSMART; layers[i] = CreateBehindLayer(&screen->LayerInfo, screen->RastPort.BitMap, x0, y0, x1, y1, flags, sb); if (layers[i]) printf("Created layer with ID %d\n",i); else printf("Couldn't create layer. No more memory (?).\n"); } else printf("No more layers possible!\n"); }
struct BitMap *AMI_ILBM_createBitMapFromScreen(amiVideo_Screen *screen) { struct BitMap *bitmap = AllocBitMap(screen->width, screen->height, screen->bitplaneDepth, BMF_DISPLAYABLE, NULL); if(bitmap != NULL) amiVideo_setScreenBitplanePointers(screen, (amiVideo_UByte**)bitmap->Planes); /* Set bitplane pointers to the bitmap */ return bitmap; }
static void scaleBitMap(struct data *data,UWORD w,UWORD h) { register UWORD x, y; if (w==data->picWidth && h==data->picHeight) return; if (w==0 || w>16383 || h==0 || h>16383) return; x = ScalerDiv(w,FACTOR,data->picWidth); y = ScalerDiv(h,FACTOR,data->picHeight); if (x==0 || x>16383 || y==0 || y>16383) return; w = ScalerDiv(x,data->picWidth,FACTOR); h = ScalerDiv(y,data->picHeight,FACTOR); if (w==0 || w>16383 || h==0 || h>16383) return; if (data->scaledBitMap = AllocBitMap(w,h,data->bmh->bmh_Depth,((data->flags & FLG_Cyber) ? BMF_MINPLANES : 0)|BMF_CLEAR,data->screen->RastPort.BitMap)) { struct BitScaleArgs scale; memset(&scale,0,sizeof(struct BitScaleArgs)); scale.bsa_SrcBitMap = data->bitMap; scale.bsa_DestBitMap = data->scaledBitMap; scale.bsa_SrcWidth = data->picWidth; scale.bsa_SrcHeight = data->picHeight; scale.bsa_XSrcFactor = FACTOR; scale.bsa_XDestFactor = x; scale.bsa_YSrcFactor = FACTOR; scale.bsa_YDestFactor = y; BitMapScale(&scale); data->scaledWidth = w; data->scaledHeight = h; scaleMask(data,data->picWidth,data->picHeight,scale.bsa_DestWidth,scale.bsa_DestHeight,x,y); SetSuperAttrs(data->cl,data->obj,MUIA_Pic_Width,w,MUIA_Pic_Height,h,TAG_DONE); } }
static void scaleMask(struct data *data,UWORD bpr,UWORD rows,UWORD dw,UWORD dh,UWORD xdf,UWORD ydf) { if (data->scaledBitMap && data->plane) { struct BitMap *bm; if (bm = AllocBitMap(dw,dh,1,0,NULL)) { struct BitScaleArgs bsa; struct BitMap sbm; memset(&sbm,0,sizeof(sbm)); sbm.BytesPerRow = RAWIDTH(bpr); sbm.Rows = rows; sbm.Depth = 1; sbm.Planes[0] = data->plane; memset(&bsa,0,sizeof(bsa)); bsa.bsa_SrcBitMap = &sbm; bsa.bsa_DestBitMap = bm; bsa.bsa_SrcWidth = data->picWidth; bsa.bsa_SrcHeight = data->picHeight; bsa.bsa_XSrcFactor = FACTOR; bsa.bsa_XDestFactor = xdf; bsa.bsa_YSrcFactor = FACTOR; bsa.bsa_YDestFactor = ydf; BitMapScale(&bsa); data->planeBitMap = bm; } } }
/************* * 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; }
int detect_screen(void) { struct Screen *myScreen; struct Window *myWindow; struct RastPort myRastPort; struct BitMap *myBitMap; APTR bitMapHandle; ULONG result; int bpp = 0; if((ULONG)IntuitionBase == 0) { IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39L); } if((ULONG)GfxBase == 0) { GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39L); } if((ULONG)CyberGfxBase == 0) { CyberGfxBase = OpenLibrary("cybergraphics.library", 0); } if(!CyberGfxBase) { if( !(CyberGfxBase=OpenLibrary("cybergraphics.library",40L))) { printf("Couldn't open cybergraphics."); return(-1); } } myScreen = LockPubScreen(NULL); if(myScreen != NULL) { UnlockPubScreen(NULL, myScreen); } else { printf("Couldnt get screen data.\n"); CloseLibrary((struct Library*)IntuitionBase); CloseLibrary(CyberGfxBase); CloseLibrary((struct Library *)GfxBase); return 5; } myBitMap = AllocBitMap(1, 1, 8, BMF_MINPLANES | BMF_DISPLAYABLE, myScreen->RastPort.BitMap); if((ULONG)myBitMap == 0) { printf("Couldnt allocate bitmap.\n"); CloseLibrary(CyberGfxBase); CloseLibrary((struct Library *)GfxBase); CloseLibrary((struct Library *)IntuitionBase); return 6; } //Creates the RastPort used for blitting InitRastPort(&myRastPort); myRastPort.BitMap = myBitMap; result=GetCyberMapAttr(myBitMap, CYBRMATTR_PIXFMT); switch(result) { case 0://PIXFMT_LUT8: bpp = 8; //printf("0"); break; case 1://PIXFMT_RGB15: bpp = 16; //printf("1"); break; case 2://PIXFMT_BGR15: bpp = 16; //printf("2"); break; case 3://PIXFMT_RGB15PC: bpp = 16; //printf("3"); break; case 4://PIXFMT_BGR15PC: bpp = 16; //printf("4"); break; case 5://PIXFMT_RGB16: bpp = 16; //printf("5"); break; case 6://PIXFMT_BGR16: bpp = 16; //printf("6"); break; case 7://PIXFMT_RGB16PC: bpp = 16; //printf("7"); break; case 8://PIXFMT_BGR16PC: bpp = 16; //printf("8"); break; case 9://PIXFMT_RGB24: bpp = 24; //printf("9"); break; case 10://PIXFMT_BGR24: bpp = 24; //printf("10"); break; case 11://PIXFMT_ARGB32: bpp = 32; //printf("11"); break; case 12://PIXFMT_BGRA32: #if defined NOVA_SDL bpp = 16; //printf("12"); #else bpp = 32; //printf("12"); #endif break; case 13://PIXFMT_RGBA32: bpp = 32; //printf("13"); break; default: bpp = 16; //printf("14"); } #ifdef DEBUG printf("Pixel format: %d \n",result); printf("Bpp: %d ",bpp); #endif FreeBitMap(myBitMap); CloseLibrary((struct Library *)IntuitionBase); //CloseLibrary(CyberGfxBase); //CloseLibrary((struct Library *)GfxBase); return bpp; }
struct DragObj * PRIVATE CreateDragObj(struct DragGadget *dg,int x,int y) { struct Screen *scr; struct RastPort *rp; struct DragObj *gdo; ULONG line; int wordwidth; int width,height,depth; int i = 0,xpos,ypos; scr = dg->dg_Window->WScreen; rp = &scr->RastPort; if (dg->dg_Flags & DGF_IMAGES && ((struct ImageNode *)dg->dg_Object.od_Object)->in_Image) dg->dg_Image = ((struct ImageNode *)dg->dg_Object.od_Object)->in_Image; if (!dg->dg_Width || !dg->dg_Height) { if ((dg->dg_Type == LISTVIEW_KIND) && !dg->dg_Image) { dg->dg_Width = dg->dg_Gadget->Width-20; dg->dg_Height = dg->dg_ItemHeight; } else if (!dg->dg_RenderHook && dg->dg_Image) { dg->dg_Width = dg->dg_Image->Width; dg->dg_Height = dg->dg_Image->Height; } else /* be sure width & height are not zero */ { dg->dg_Width = dg->dg_Gadget->Width; dg->dg_Height = dg->dg_Gadget->Height; } } width = dg->dg_Width; height = dg->dg_Height; memset(&dm,0,sizeof(struct DropMessage)); if (dg->dg_Type == LISTVIEW_KIND) { xpos = dg->dg_Gadget->LeftEdge+2; ypos = dg->dg_Gadget->TopEdge+2; dg->dg_Object.od_Object = NULL; if (y < ypos || y > ypos+dg->dg_Gadget->Height-5) return(NULL); line = (y-ypos)/dg->dg_ItemHeight; ypos += line*dg->dg_ItemHeight; GT_GetGadgetAttrs(dg->dg_Gadget,dg->dg_Window,NULL,GTLV_Labels,&dg->dg_List,TAG_END); if (dg->dg_List && !IsListEmpty(dg->dg_List)) { GT_GetGadgetAttrs(dg->dg_Gadget,dg->dg_Window,NULL,GTLV_Top,&i,TAG_END); i += line; if (i < CountNodes(dg->dg_List)) { struct Node *ln; dm.dm_SourceEntry = i; for(ln = dg->dg_List->lh_Head;i;i--,ln = ln->ln_Succ); if (dg->dg_Flags & DGF_TREEVIEW && TREENODE(ln)->tn_Flags & TNF_STATIC) { mx = ~0L; // avoid a following drag return(NULL); } dg->dg_Object.od_Object = ln; if (dg->dg_ObjectFunc) dg->dg_ObjectFunc(dg->dg_Window,dg->dg_Gadget,&dg->dg_Object,dm.dm_SourceEntry); } } } else { if (dg->dg_ObjectFunc) dg->dg_ObjectFunc(dg->dg_Window,dg->dg_Gadget,&dg->dg_Object,0L); dm.dm_SourceEntry = dg->dg_SourceEntry; xpos = x-width/2; ypos = y-height/2; } if (!dg->dg_Object.od_Object) { mx = ~0L; // avoid a following drag return(NULL); } wordwidth = (width + 15) >> 4; depth = GetBitMapAttr(rp->BitMap,BMA_DEPTH); if (dg->dg_Object.od_Object && (gdo = AllocMem(sizeof(struct DragObj), MEMF_CLEAR | MEMF_PUBLIC))) { #ifdef LOCKLAYERS LockLayers(&scr->LayerInfo); UnlockLayer(dg->dg_Window->RPort->Layer); #endif gdo->do_Screen = scr; gdo->do_ScrRPort = rp; gdo->do_BitMap = AllocBitMap(width,height,depth,BMF_CLEAR | BMF_MINPLANES,!(GetBitMapAttr( rp->BitMap, BMA_FLAGS ) & BMF_INTERLEAVED) ? rp->BitMap : NULL); gdo->do_SaveBack = AllocBitMap(width,height,depth,BMF_CLEAR | BMF_MINPLANES,rp->BitMap); gdo->do_RefreshMap = AllocBitMap(width*2,height*2,depth,BMF_CLEAR | BMF_MINPLANES,rp->BitMap); if (GetBitMapAttr(gdo->do_BitMap,BMA_FLAGS) & BMF_STANDARD) i = MEMF_CHIP | MEMF_PUBLIC; else i = 0; gdo->do_FullShadow = AllocMem(2*wordwidth*height,i | MEMF_CLEAR); gdo->do_HalfShadow = AllocMem(2*wordwidth*height,i); if (gdo->do_BitMap && gdo->do_SaveBack && gdo->do_RefreshMap && gdo->do_FullShadow && gdo->do_HalfShadow) { InitRastPort(&gdo->do_RPort); gdo->do_RPort.BitMap = gdo->do_BitMap; InitRastPort(&gdo->do_RefreshRPort); gdo->do_RefreshRPort.BitMap = gdo->do_RefreshMap; gdo->do_DragGadget = dg; CopyMem(&dg->dg_Object,&dm.dm_Object,sizeof(struct ObjectDescription)); dm.dm_Window = dg->dg_Window; dm.dm_Gadget = dg->dg_Gadget; /*** create the drag&drop image ***/ if (dg->dg_RenderHook) { struct LVDrawMsg lvdm; SetFont(&gdo->do_RPort,scr->RastPort.Font); lvdm.lvdm_MethodID = LV_DRAW; lvdm.lvdm_RastPort = &gdo->do_RPort; lvdm.lvdm_DrawInfo = GetScreenDrawInfo(scr); lvdm.lvdm_Bounds.MinX = 0; lvdm.lvdm_Bounds.MinY = 0; lvdm.lvdm_Bounds.MaxX = width-1; lvdm.lvdm_Bounds.MaxY = height-1; lvdm.lvdm_State = LVR_SELECTED; CallHookPkt(dg->dg_RenderHook,dm.dm_Object.od_Object,&lvdm); FreeScreenDrawInfo(scr,lvdm.lvdm_DrawInfo); } else if (dg->dg_Image) DrawImage(&gdo->do_RPort,dg->dg_Image,0,0); else ClipBlit(dg->dg_Window->RPort,xpos,ypos,&gdo->do_RPort,0,0,width,height,0xc0); /*** initialize drag object structure ***/ gdo->do_X = -9999; gdo->do_Y = ypos+dg->dg_Window->TopEdge; gdo->do_PX = -9999; gdo->do_Width = width; gdo->do_Height = height; gdo->do_DeltaX = xpos-x+dg->dg_Window->LeftEdge; gdo->do_DeltaY = ypos-y+dg->dg_Window->TopEdge; gdo->do_Mask = gdo->do_FullShadow; /*** create masks (transparent and full imagery) ***/ if (CyberGfxBase && (GetBitMapAttr(gdo->do_BitMap,BMA_FLAGS) & BMF_STANDARD) == 0L) { struct BitMap tbm; ULONG col; InitBitMap(&tbm,1,width,height); tbm.Planes[0] = (UBYTE *)gdo->do_FullShadow; /* if (!GetCyberMapAttr(gdo->do_BitMap, CYBRMATTR_PIXELFMT)) */ if (GetBitMapAttr(gdo->do_BitMap, BMA_DEPTH) > 8L) { ULONG triplet[3]; GetRGB32(scr->ViewPort.ColorMap,0L,1L,triplet); col = (triplet[0] & 0xff0000) | (triplet[1] & 0xff00) | (triplet[2] & 0xff); } else col = 0; // ExtractColor(rp,&tbm,col,xpos,ypos,width,height); ExtractColor(&gdo->do_RPort,&tbm,col,0,0,width,height); BltBitMap(&tbm,0,0,&tbm,0,0,width,height,0x50,0xff,NULL); // invertieren der Maske } else { UWORD *p = gdo->do_FullShadow; for(ypos = 0;ypos < height;ypos++) { for(xpos = 0;xpos < wordwidth;xpos++,p++) { for(i = 0;i < depth;i++) *p |= *((UWORD *)gdo->do_BitMap->Planes[i]+ypos*(gdo->do_BitMap->BytesPerRow >> 1)+xpos); } } } { UWORD *p = gdo->do_HalfShadow; CopyMem(gdo->do_FullShadow,p,2*wordwidth*height); for(line = 0x5555,ypos = 0;ypos < height;ypos++) { line = ~line; for(xpos = 0;xpos < wordwidth;xpos++,p++) *p &= (UWORD)line; } } if (!boopsigad) FakeInputEvent(); UpdateDragObj(gdo,gdo->do_X,gdo->do_Y); /* show drag object */ return(gdo); }
APTR ReadBitMapA(struct BitMap *bm, UWORD displayID, PALETTE palette, int *ptr_pixelformat, int *ptr_width, int *ptr_height, TAGLIST tags) { APTR array = NULL; if (bm) { BOOL success; int sourcex, sourcey, sourcewidth, sourceheight, destwidth, destheight; int width, height, flags, depth, iscyber, bmapformat, pixelformat; int bufsize; APTR scaleengine = NULL; struct RastPort rp, temprp; sourcex = GetTagData(GGFX_SourceX, 0, tags); sourcey = GetTagData(GGFX_SourceY, 0, tags); GetBitMapInfo(bm, displayID, BMAPATTR_Width, &width, BMAPATTR_Height, &height, BMAPATTR_Depth, &depth, BMAPATTR_Flags, &flags, BMAPATTR_CyberGFX, &iscyber, BMAPATTR_BitMapFormat, &bmapformat, BMAPATTR_PixelFormat, &pixelformat, TAG_DONE); sourcewidth = GetTagData(GGFX_SourceWidth, width, tags); sourceheight = GetTagData(GGFX_SourceHeight, height, tags); destwidth = GetTagData(GGFX_DestWidth, width, tags); destheight = GetTagData(GGFX_DestHeight, height, tags); success = TRUE; // insert bitmap into rastport, create temp rastport InitRastPort(&rp); rp.BitMap = bm; TurboCopyMem(&rp, &temprp, sizeof(struct RastPort)); temprp.Layer = NULL; if (!(temprp.BitMap = AllocBitMap(width, 1, depth, flags, bm))) { success = FALSE; } // create scale engine if (success) { if (sourcewidth != destwidth || sourceheight != destheight) { if (!(scaleengine = CreateScaleEngine( sourcewidth, sourceheight, destwidth, destheight, RND_RMHandler, MemHandler, RND_PixelFormat, pixelformat, TAG_DONE))) { success = FALSE; } } } // get buffer if (success) { if (pixelformat == PIXFMT_0RGB_32) { bufsize = destwidth * destheight * PIXELSIZE(pixelformat); } else { bufsize = ((destwidth+15) & ~15) * destheight; } DB(kprintf("!readbitmap alloc\n")); if (!(array = AllocRenderVec(MemHandler, bufsize))) { success = FALSE; } } // convert data if (success) { success = FALSE; if (scaleengine) { // with scaling switch (bmapformat) { case PIXFMT_BITMAP_RGB: { ULONG *linebuffer; DB(kprintf("~reading/scaling RGB bitmap\n")); if (linebuffer = AllocRenderVec(MemHandler, sourcewidth * 4)) { struct Hook readhook; struct readrgbdata hookdata; hookdata.rp = &rp; hookdata.sourcex = sourcex; hookdata.sourcey = sourcey; hookdata.sourcewidth = sourcewidth; hookdata.lastline = -1; readhook.h_Data = &hookdata; readhook.h_Entry = HOOKENTRY(readrgb); Scale(scaleengine, linebuffer, array, RND_SourceWidth, 0, RND_LineHook, &readhook, TAG_DONE); FreeRenderVec(linebuffer); success = TRUE; } break; } case PIXFMT_BITMAP_CLUT: { UBYTE *linebuffer; DB(kprintf("~reading/scaling CLUT bitmap\n")); if (linebuffer = AllocRenderVec(MemHandler, ((sourcewidth+15) & ~15))) { struct Hook readhook; struct readclutdata hookdata; hookdata.rp = &rp; hookdata.temprp = &temprp; hookdata.sourcex = sourcex; hookdata.sourcey = sourcey; hookdata.sourcewidth = sourcewidth; hookdata.lastline = -1; readhook.h_Data = &hookdata; readhook.h_Entry = HOOKENTRY(readclut); Scale(scaleengine, linebuffer, array, RND_SourceWidth, 0, RND_LineHook, &readhook, TAG_DONE); FreeRenderVec(linebuffer); success = TRUE; } break; } case PIXFMT_BITMAP_HAM6: case PIXFMT_BITMAP_HAM8: { UBYTE *linebuffer; ULONG *rgbbuffer; DB(kprintf("~reading/scaling HAM bitmap\n")); if (linebuffer = AllocRenderVec(MemHandler, ((sourcewidth + sourcex + 15) & ~15))) { if (rgbbuffer = AllocRenderVec(MemHandler, sourcewidth * 4)) { struct Hook readhook; struct readhamdata hookdata; hookdata.rp = &rp; hookdata.temprp = &temprp; hookdata.sourcex = sourcex; hookdata.sourcey = sourcey; hookdata.sourcewidth = sourcewidth; hookdata.linebuffer = linebuffer; hookdata.palette = palette; hookdata.colormode = (depth == 8) ? COLORMODE_HAM8 : COLORMODE_HAM6; hookdata.lastline = -1; readhook.h_Data = &hookdata; readhook.h_Entry = HOOKENTRY(readham); Scale(scaleengine, rgbbuffer, array, RND_SourceWidth, 0, RND_LineHook, &readhook, TAG_DONE); FreeRenderVec(rgbbuffer); success = TRUE; } FreeRenderVec(linebuffer); } break; } } } else { // no scaling switch (bmapformat) { case PIXFMT_BITMAP_RGB: { DB(kprintf("~reading RGB bitmap\n")); ReadPixelArray(array, 0,0, destwidth * 4, &rp, sourcex, sourcey, destwidth, destheight, RECTFMT_ARGB); success = TRUE; break; } case PIXFMT_BITMAP_CLUT: { int i; char *p = array; DB(kprintf("~reading CLUT bitmap\n")); for(i = 0; i < destheight; ++i) { ReadPixelLine8(&rp, sourcex, sourcey + i, destwidth, p, &temprp); p += destwidth; } success = TRUE; break; } case PIXFMT_BITMAP_HAM6: case PIXFMT_BITMAP_HAM8: { UBYTE *linebuffer; DB(kprintf("~reading HAM bitmap\n")); if (linebuffer = AllocRenderVec(MemHandler, ((destwidth+15) & ~15) )) { int i; ULONG *p = array; for(i = 0; i < destheight; ++i) { ReadPixelLine8(&rp, sourcex, sourcey + i, destwidth, linebuffer, &temprp); Chunky2RGB(linebuffer, destwidth, 1, p, palette, RND_ColorMode, ((depth == 8) ? COLORMODE_HAM8 : COLORMODE_HAM6), TAG_DONE); p += destwidth; } FreeRenderVec(linebuffer); success = TRUE; } break; } } } } // close down if (success) { *ptr_pixelformat = pixelformat; *ptr_width = destwidth; *ptr_height = destheight; } else { if (array) { FreeRenderVec(array); array = NULL; } } if (scaleengine) { DeleteScaleEngine(scaleengine); } if (temprp.BitMap) { FreeBitMap(temprp.BitMap); } } return array; }
/* * Check whether the appearance of the VSprite has been changed * somehow. If for example the Image Data has changed, then * I will try to update the BitMap of the IntVSprite structure * to the new image data. */ BOOL _ValidateIntVSprite(struct IntVSprite * ivs, struct RastPort * rp, BOOL force_change, struct GfxBase * GfxBase) { struct VSprite * vs = ivs->VSprite; /* * Check whether the ImageData pointer has changed */ if (vs->ImageData != ivs->OrigImageData || force_change) { struct BitMap bm; #if 0 kprintf("%s: Imagedata has changed (old:%p-new:%p)!\n", __FUNCTION__, vs->ImageData, ivs->OrigImageData); kprintf("PlanePick: %02x, rp->BitMap:%p\n",vs->PlanePick,rp->BitMap); #endif /* * Only need to get a new bitmap if * something in the size of the bob has changed. */ if ((ivs->Width != vs->Width ) || (ivs->Height != vs->Height) || (ivs->Depth != vs->Depth ) ) { if (NULL != ivs->ImageData) FreeBitMap(ivs->ImageData); if (NULL != ivs->SaveBuffer) FreeBitMap(ivs->SaveBuffer); /* * Now get a new bitmap */ ivs->ImageData = AllocBitMap(vs->Width<<4, vs->Height, vs->Depth, BMF_CLEAR, rp->BitMap); ivs->SaveBuffer = AllocBitMap(vs->Width<<4, vs->Height, vs->Depth, 0, rp->BitMap); ivs->Width = vs->Width; ivs->Height = vs->Height; ivs->Depth = vs->Depth; } ivs->OrigImageData = vs->ImageData; /* * Blit the image data from the VSprite into the * ImageData (BitMap) of the IntVSprite */ InitBitMap(&bm, ivs->Depth, ivs->Width<<4, ivs->Height); { UBYTE *imagedata = (UBYTE *)vs->ImageData; WORD d, shift; for (d = 0, shift = 1; d < 8; d++, shift *= 2) { if (vs->PlanePick & shift) { bm.Planes[d] = imagedata; imagedata += (bm.Rows * bm.BytesPerRow); } else { bm.Planes[d] = (vs->PlaneOnOff & shift) ? (PLANEPTR)-1 : NULL; } } } BltBitMap(&bm, 0, 0, ivs->ImageData, 0, 0, ivs->Width << 4, ivs->Height, 0x0c0, vs->PlanePick, NULL); } return TRUE; }
HISTORY *****************************************************************************/ { AROS_LIBFUNC_INIT /* First allocate a BitMap where the BitMap Data of the RastPort's bitmap will go into. */ struct BitMap * NewBM; NewBM = AllocBitMap(GetBitMapAttr(cr->BitMap, BMA_WIDTH) + 16, GetBitMapAttr(cr->BitMap, BMA_HEIGHT), GetBitMapAttr(cr->BitMap, BMA_DEPTH), 0, rp->BitMap); /* Save the displayed bitmap area to the new BitMap */ BltBitMap(rp->BitMap, cr->bounds.MinX, cr->bounds.MinY, NewBM, ALIGN_OFFSET(cr->bounds.MinX), 0, cr->bounds.MaxX - cr->bounds.MinX + 1, cr->bounds.MaxY - cr->bounds.MinY + 1, 0x0c0,
void DemoD() { int i; int c; struct BitMap * sb; printf("Deleting all previously generated layers...\n"); for (i = 0; i < 10; i++) { if (layers[i]) { DeleteLayer(0, layers[i]); layers[i] = NULL; } } i = 0; printf("Creating 4 superbitmap layers\n"); sb = AllocBitMap(91,91,1,BMF_CLEAR,NULL); layers[0] = CreateUpfrontLayer(&screen->LayerInfo, screen->RastPort.BitMap, 10, 10, 100, 100, LAYERSMART|LAYERSUPER, sb); frame(layers[0]); sb = AllocBitMap(71,71,1,BMF_CLEAR,NULL); layers[1] = CreateUpfrontLayer(&screen->LayerInfo, screen->RastPort.BitMap, 50, 50, 120, 120, LAYERSMART|LAYERSUPER, sb); frame(layers[1]); sb = AllocBitMap(71,61,1,BMF_CLEAR,NULL); layers[2] = CreateUpfrontLayer(&screen->LayerInfo, screen->RastPort.BitMap, 70, 30, 140, 90, LAYERSMART|LAYERSUPER, sb); frame(layers[2]); sb = AllocBitMap(131,41,1,BMF_CLEAR,NULL); layers[3] = CreateUpfrontLayer(&screen->LayerInfo, screen->RastPort.BitMap, 20, 20, 150, 60, LAYERSMART|LAYERSUPER, sb); frame(layers[3]); printf("Resizing layer 4\n"); Delay(30); SizeLayer(0, layers[3], -80, -10); /* this leaves width = 51, height = 31 */ printf("Scrolling layer 4\n"); Delay(30); c = 0; while (c < 80) { c++; Delay(5); ScrollLayer(0, layers[3], 1, 0); } c = 0; while (c < 10) { c++; Delay(5); ScrollLayer(0, layers[3], 0 ,1); } c = 0; while (c < 10) { c++; Delay(5); ScrollLayer(0, layers[3], -8 ,-1); } printf("Resizing layer 4 to its full size\n"); Delay(30); SizeLayer(0, layers[3], 80, 10); printf("Resizing layer 1\n"); SizeLayer(0, layers[0], -50, -50); /* this leaves width = 41, height = 41 */ printf("Scrolling layer 1\n"); Delay(30); c = 0; while (c < 41) { c++; Delay(5); ScrollLayer(0, layers[0], 1, 0); } c = 0; while (c < 41) { c++; Delay(5); ScrollLayer(0, layers[0], 0 ,1); } c = 0; while (c < 41) { c++; Delay(5); ScrollLayer(0, layers[0], -1 ,-1); } printf("Resizing layer 1 to its full size\n"); Delay(30); SizeLayer(0, layers[0], 50, 50); printf("Shuffling layers...\n"); UpfrontLayer(0, layers[0]); Delay(20); UpfrontLayer(0, layers[1]); Delay(20); UpfrontLayer(0, layers[2]); Delay(20); UpfrontLayer(0, layers[3]); Delay(20); BehindLayer(0, layers[2]); Delay(20); BehindLayer(0,layers[1]); Delay(20); BehindLayer(0,layers[0]); printf("Inviting a few smart friends...\n"); GenerateLayers3(); printf("Moving the layers...\n"); c = 0; while (c < 40) { MoveLayer(0, layers[4], -1, -1); MoveLayer(0, layers[0], 1,2); MoveLayer(0, layers[2], 2,1); MoveLayer(0, layers[5], -2, 0); c++; } c = 0; while (c < 30) { MoveLayer(0, layers[4], -1, -1); MoveLayer(0, layers[5], -1, 0); MoveLayer(0, layers[3], 3, 2); MoveSizeLayer(layers[2], 2, -1, -1, -1); c++; } c = 0; while (c < 30) { MoveSizeLayer(layers[2], -2, 1, 1 ,1); MoveSizeLayer(layers[1], 2, 0, -1 ,-1); MoveLayer(0, layers[5], 2, 1); c++; } c = 0; while (c < 30) { MoveSizeLayer(layers[1], -1, -1 ,1 , 1); c++; } printf("Deleting the layers...\n"); i = 0; while (i < 8) { while ((layers[i]->bounds.MaxX - layers[i]->bounds.MinX) >= 1 && (layers[i]->bounds.MaxY - layers[i]->bounds.MinY) >= 1) { MoveSizeLayer(layers[i], 2, 0, -1, -1); } DeleteLayer(0, layers[i]); layers[i] = NULL; i++; } }
///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; }