Web site:  http://openamiga.org  Open Amiga - Projects20241222 05:22
Content ID:  21
Content title:  Global images

Guideline - Gadget images
<- Back to guidelines

Content
    
- Intro
- How to load images


Intro

More and more applications and utilities has started to use/require the AISS* image set for gadget imagery. To avoid creating our own standard, OpenAmiga projects shall use AISS as well.

Since the full AISS image set is not shipped with OS4 OpenAmiga projects must make sure that all images they need are accounted for.

Always make sure that your images use the same file names as used by AISS to avoid compatibility issues. Contact Mason if there's any images that are missing in the AISS package to find out how to deal with them.

Openamiga projects shall scan for images in this order:
    
- progdir:
- progdir:images/
- TBImages:


This way you can ship all necessary images with your application without requiring that AISS is installed. But it also allows the user to copy the images into the AISS framwork and your application will still find its images.

* AISS is a 3rd party package made by Martin "Mason" Merz that provides a large range of gadget imagery. Allowing different applications to use the same images for the same functions.

How to load images

Loading a single image:
struct Screen *AppScreen = IIntuition->LockPubScreen(NULL);

// To allocate your bitmap:
struct Image myImage* = BitMapObject, BITMAP_SourceFile,
                        (STRPTR)"copy",
                        BITMAP_Screen, AppScreen,
                        BITMAP_Precision, PRECISION_EXACT,
                        BITMAP_Masking,TRUE, End;

// You must also dispose the bitmap once done with it.

IIntuition->DisposeObject(myImage);
IIntuition->UnlockPubScreen(NULL,AppScreen);


Checking several source folders:
char buffer[512];

IUtility->Strlcpy(buffer,"progdir:",512);
IDOS->AddPart(buffer,myimagename,512);
myImage = LoadImage((STRPTR)buffer, AppScreen);
if (!myImage) // could not find images in progdir:
{
 IUtility->Strlcpy(buffer,"progdir:images/",512);
 IDOS->AddPart(buffer,myimagename,512);
 myImage = LoadImage((STRPTR)buffer, AppScreen);
}

if (!myImage) // could not find images in progdir:images
{
 IUtility->Strlcpy(buffer,"TBImages:",512);
 IDOS->AddPart(buffer,myimagename,512);
 myImage = LoadImage((STRPTR)buffer, AppScreen);
}

if (!myImage)
{
 // Could not find image file!
 // .. handle the error ..
}

// Where LoadImage() is:

struct Image *LoadImage(STRPTR buffer, struct Screen *AppScreen)
{
 return BitMapObject,
        BITMAP_SourceFile, buffer,
        BITMAP_Screen, AppScreen,
        BITMAP_Precision, PRECISION_EXACT,
        BITMAP_Masking,TRUE,
        End;
}