Example #1
0
VOID _DeleteIntVSprite(struct VSprite * vs,
                       struct GfxBase * GfxBase)
{
	struct IntVSprite * ivs = vs->IntVSprite;

	if (NULL != ivs) {
		if (NULL != ivs->ImageData)
			FreeBitMap(ivs->ImageData);

		if (NULL != ivs->SaveBuffer)
			FreeBitMap(ivs->SaveBuffer);
		
		FreeMem(ivs, sizeof(struct IntVSprite));
		vs->IntVSprite = NULL;
	}
}
Example #2
0
/* This gets rid of the "original" bitmap and sets the state to "no transform" */
void ClearBrXform()
{
    FreeBitMap( &origBM );
    DFree( origBr.mask );
    origBr.mask = NULL;
    curBrXform = NOXFORM;
}
Example #3
0
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);
}
Example #4
0
void FreeSpare()
{
    if ( spareThere ) {
        FreeBitMap( &sparebm );
    }
    spareThere = NO;
}
Example #5
0
void AMI_ILBM_destroyImage(AMI_ILBM_Image *image)
{
    CloseScreen(image->intuitionScreen);
    FreeBitMap(image->bitmap);
    amiVideo_cleanupScreen(&image->screen);
    AMI_ILBM_cleanupRangeTimes(&image->rangeTimes);
}
Example #6
0
VOID RenderMessage::FlushDoubleBuffer ()
{
  if(BufferRP)
  {
    WaitBlit();
    FreeBitMap(BufferRP->BitMap);
    delete BufferRP;
    BufferRP = NULL;
  }
}
void PRIVATE FreeDragObj(struct DragObj *gdo)
{
  if (!gdo)
    return;

  if (hdg)
    HighlightDragGadget(NULL,0,0);
  else
    UpdateDragObj(gdo,0,-9999);

#ifdef LOCKLAYERS
  LockLayer(0,gdo->do_DragGadget->dg_Window->RPort->Layer);
  UnlockLayers(&gdo->do_Screen->LayerInfo);
#endif

  FreeBitMap(gdo->do_BitMap);
  FreeBitMap(gdo->do_SaveBack);
  FreeBitMap(gdo->do_RefreshMap);
  FreeMem(gdo->do_FullShadow,((gdo->do_Width+15) >> 4)*2*gdo->do_Height);
  FreeMem(gdo->do_HalfShadow,((gdo->do_Width+15) >> 4)*2*gdo->do_Height);
  FreeMem(gdo,sizeof(struct DragObj));
}
Example #8
0
void freelayers(void)
{
  int i;
  for (i=0; i < 10; i++) 
  {
    if (NULL != layers[i])
    {
      DeleteLayer(0, layers[i]);
      if (layers[i]->SuperBitMap)
        FreeBitMap(layers[i]->SuperBitMap);
    }
  }
}
Example #9
0
IPTR Prop__OM_DISPOSE(struct IClass *cl, Object *obj, Msg msg)
{
    struct Prop_DATA *data = INST_DATA(cl, obj);

    if (data->prop_object && !data->usewinborder) {
        RemoveGadget(_window(obj), (struct Gadget *) data->prop_object);
        DisposeObject(data->prop_object);
    }

    DisposeImageContainer(data->buffer);
    DisposeImageContainer(data->temp);
    if (data->mapbuffer != NULL) FreeBitMap(data->mapbuffer);
    if (data->maptemp != NULL) FreeBitMap(data->maptemp);
    if (data->tmprp != NULL) FreeRastPort(data->tmprp);

    data->buffer = NULL;
    data->temp = NULL;
    data->mapbuffer = NULL;
    data->maptemp = NULL;
    data->tmprp = NULL;

    return DoSuperMethodA(cl, obj, msg);
}
Example #10
0
void KillDisplay() {
  if (Display) {
    size_t i;

    CloseScreen(Display->Screen);

    for (i = 0; i < 2; i++)
      FreeBitMap(Display->Bitmap[i]);

    MemUnref(Display->Palette);
    MemUnref(Display);

    Display = NULL;
  }
}
Example #11
0
void deletelayer(void)
{
  int i;
  printf("Delete layer with id: ");
  scanf("%d", &i);
  if (layers[i]) 
  {
    DeleteLayer(0, layers[i]);
    if (layers[i]->SuperBitMap)
      FreeBitMap(layers[i]->SuperBitMap);
    printf("Deleted layer with id %d\n",i);
    layers[i] = NULL;
  } 
  else 
  {
    printf("No layer with id %d\n",i);
  }
}
Example #12
0
///ImageBackFill_CloseSourceBuffer()
static void ImageBackFill_CloseSourceBuffer(struct BackFillSourceImageRecord *this_Record, struct BackFillSourceImageBuffer *this_Buffer)
{
  D(bug("[IconWindow.ImageBackFill] ImageBackFill_CloseSourceBuffer()\n"));
  if (this_Buffer->bfsib_OpenerCount >= 2)
  {
    this_Buffer->bfsib_OpenerCount -= 1;
    D(bug("[IconWindow.ImageBackFill] ImageBackFill_CloseSourceBuffer: %d Openers Remaining\n", this_Buffer->bfsib_OpenerCount));
    return;
  }
  else
  {
    Remove((struct Node *)this_Buffer);
    this_Buffer->bfsib_OpenerCount = 0;
    D(bug("[IconWindow.ImageBackFill] ImageBackFill_CloseSourceBuffer: Closing Buffer [%d x %d] of '%s'\n", this_Buffer->bfsib_BitMapWidth, this_Buffer->bfsib_BitMapHeight, this_Record->bfsir_SourceImage));

    this_Buffer->bfsib_BitMapRastPort->BitMap = NULL;
    FreeRastPort(this_Buffer->bfsib_BitMapRastPort);
    FreeBitMap(this_Buffer->bfsib_BitMap);
    FreeMem(this_Buffer, sizeof(struct BackFillSourceImageBuffer));
  }
}
Example #13
0
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;
}
Example #14
0
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;
}
Example #15
0
///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;
}
Example #16
0
/*************
 * 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;
}
Example #17
0
/*
 * 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;
}