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 1427 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline nyteschaydeTopic starter

  • VIP / Donor - Lifetime Member
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 643
    • Show only replies by nyteschayde
    • http://www.nyteshade.com
I have been trying to find place that describes how to load an image and present it with code. Things that would be nice to understand:

  • How to load an image pre-datatypes
  • How to load an image with datatypes
  • How to display an image in a regular window
  • How to display an image directly to a screen


  • Examples on how to do this with <=3.1 would be great
  • Examples on how to do this with >3.1 would also be enlightening
  • Examples on how to do this with 24-bit images would be welcomed


  • What types of images are supported without datatypes? ILBM? Anything else?
  • Any info on tools you might use to convert PNGs, JPGs and more to ILBM
  • Anything else along these lines


Thanks in advance.
Senior MTS Software Engineer with PayPal
Amigas: A1200T 060/603e PPC • A1200T 060 • A4000D 040 • A3000 (x2) • A2000 Vamp/V2 • A1200 (x4) • A1000 (x3) • A600 Vamp/V1 • A500
 

Offline Thomas

Re: 68K Dev Question: How do I work with images in C or C++ on the Amiga?
« Reply #1 on: January 30, 2015, 07:02:11 AM »
Quote
What types of images are supported without datatypes?


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

Offline nyteschaydeTopic starter

  • VIP / Donor - Lifetime Member
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 643
    • Show only replies by nyteschayde
    • http://www.nyteshade.com
Re: 68K Dev Question: How do I work with images in C or C++ on the Amiga?
« Reply #2 on: January 31, 2015, 11:46:10 PM »
Thomas, do you have any quick examples on how to do what I asked in C or C++? Clearly with datatypes since it would seem that coming up with your own bitmap format or writing a parser for a bitmap would be a waste of time unless you were limited to OS1.3 or (when did they add datatypes? 2.x?)
Senior MTS Software Engineer with PayPal
Amigas: A1200T 060/603e PPC • A1200T 060 • A4000D 040 • A3000 (x2) • A2000 Vamp/V2 • A1200 (x4) • A1000 (x3) • A600 Vamp/V1 • A500
 

Offline Thomas

Re: 68K Dev Question: How do I work with images in C or C++ on the Amiga?
« Reply #3 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);
}