Welcome, Guest. Please login or register.

Author Topic: 68K Dev Question: How do I work with images in C or C++ on the Amiga?  (Read 3168 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Thomas

Quote
What types of images are supported without datatypes?


None, not even ILBM. You have to write all loading/unpacking code yourself.

Offline Thomas

Re: 68K Dev Question: How do I work with images in C or C++ on the Amiga?
« Reply #1 on: February 01, 2015, 10:37:47 AM »
Datatypes appeared in 3.0.

Here is an example which tells datatypes to dither the loaded image into the screen's pixel format and/or palette:

Code: [Select]

/* compile with vc +aos68k dtview.c -o dtview -lauto -lamiga */

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/datatypes.h>

#include <datatypes/pictureclass.h>

#include <clib/alib_protos.h>

int main (void)

{
int rc = RETURN_FAIL;

static struct {
char *file;
char *pubscreen;
} args = {NULL};

struct RDArgs *rdargs = ReadArgs (&quot;FILE/A,PUBSCREEN/K&quot;, (APTR)&args, NULL);

if (rdargs)
{
struct Screen *scr = LockPubScreen (args.pubscreen);

if (scr)
{
Object *dto = NewDTObject (args.file,
DTA_GroupID, GID_PICTURE,
PDTA_Remap, TRUE,
PDTA_Screen, scr,
PDTA_DestMode, PMODE_V43,
TAG_END);

if (dto)
{
struct BitMapHeader *bmhd = NULL;
struct BitMap *bm = NULL;

DoMethod (dto, DTM_PROCLAYOUT, NULL, TRUE);

GetDTAttrs (dto,
PDTA_BitMapHeader, &bmhd,
PDTA_DestBitMap, &bm,
TAG_END);

if (bmhd && bm)
{
struct Window *win = OpenWindowTags (NULL,
WA_Title, FilePart(args.file),
WA_InnerWidth, bmhd->bmh_Width,
WA_InnerHeight, bmhd->bmh_Height,
WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_ACTIVATE | WFLG_NOCAREREFRESH,
WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY,
TAG_END);

if (win)
{
BOOL cont = TRUE;

BltBitMapRastPort (bm, 0, 0, win->RPort,
win->BorderLeft, win->BorderTop,
win->GZZWidth, win->GZZHeight,
ABC | ABNC);

do {
struct IntuiMessage *imsg;

if (Wait ((1L << win->UserPort->mp_SigBit) | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
cont = FALSE;

while ((imsg = (struct IntuiMessage *) GetMsg (win->UserPort)))
{
switch (imsg->Class)
{
case IDCMP_VANILLAKEY:
if (imsg->Code == 0x1b) /* Esc */
cont = FALSE;
break;
case IDCMP_CLOSEWINDOW:
cont = FALSE;
break;
}
ReplyMsg ((struct Message *) imsg);
}
}
while (cont);

CloseWindow (win);

rc = RETURN_OK;
}
}

DisposeDTObject (dto);
}

UnlockPubScreen (NULL, scr);
}

FreeArgs (rdargs);
}

if (rc != RETURN_OK)
PrintFault (IoErr(), NULL);

return (rc);
}