Amiga.org
Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: Morbane on January 09, 2012, 04:35:16 AM
-
I would like to learn how to load or program a picture into a window. ANyone have the necessary C code examples or tutorial for that?
I am trying my hand for the first time to program in the AmigaOS environment. I am familiar with most debugging messages and can muddle my through tutorials - I have only been at it for a week and have mad enough progress to say loosely I have learned a fewthingd about Screens and windows. But I am trolling for mor information. I am Using Louis Se GCC environment - I really like the way it is set up and I am trying to get the basics down but this loading and keeping an image in a window is giving me trouble - mayhaps someone has a lexicon of sorts that explaina the GCC library structure as I am pretty sure I need a more developed Library cache - many of the examples I have found do not compile and the error list is mostly in something like assembler or the like. I am used to debugging: on line 57 etc etc but the errors i get look like this:
(http://img404.imageshack.us/img404/6686/49307467.png) (http://imageshack.us/photo/my-images/404/49307467.png/)
Any suggestions are greatly welcome and appreciated.:)
-
Try this kind of thang...
GfxBase = (struct GfxBase*)OpenLibrary( "graphics.library", 0L);
if (!GfxBase) {
error("Could not open the Graphics library");
}
IntuitionBase = (struct IntuitionBase*)OpenLibrary( "intuition.library", 0L);
if (!IntuitionBase) {
error("Could not open the Intuition library");
}
-
Not sure where you are at... So I'll point you right at the start :)
http://www.liquido2.com/tutorial/hello_world.html
-
Yep - been using those tutorials mostly - they are really a good place to learn but they only go as far as a simple selecter program - which is cool nd it will come in handy - the getting an image into a window is the heart of my frustration.
A little nudge in the code direction would be helpful.
Nova - that code, I am pretty sure is just an error trap - not very load-an-image based though. but thank anyway. If it does more would you mind explaining it to me?
-
These are linker errors.
The C environment accesses IntuitionBase, DataTypesBase and GfxBase as global variables, but they are not defined in any module.
This should be fixed by adding the following include references as they define the globals you need:
#include
#include
#include
Good luck.
-
These are linker errors.
The C environment accesses IntuitionBase, DataTypesBase and GfxBase as global variables, but they are not defined in any module.
This should be fixed by adding the following include references as they define the globals you need:
#include
#include
#include
Good luck.
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/datatypes.h>
#include <datatypes/pictureclass.h>
int main (void)
{
struct RDArgs *rdargs;
struct {
char *file;
char *pubscreen;
} args = {0};
int rc = RETURN_FAIL;
struct Screen *scr;
Object *dto;
struct BitMapHeader *bmhd;
struct BitMap *bm;
WORD winw,winh;
struct Window *win;
struct IntuiMessage *imsg;
BOOL cont;
rdargs = ReadArgs ("FILE/A,PUBSCREEM/K",(LONG *)&args,NULL);
if (!rdargs)
{
PrintFault (IoErr(),NULL);
return (RETURN_FAIL);
}
if (scr = LockPubScreen (args.pubscreen))
{
if (dto = NewDTObject (args.file,DTA_GroupID,GID_PICTURE,PDTA_Remap,TRUE,PDTA_Screen,scr,TAG_END))
{
DoDTMethod (dto,NULL,NULL,DTM_PROCLAYOUT,NULL,TRUE);
GetDTAttrs (dto,(ULONG) PDTA_BitMapHeader,&bmhd,(ULONG) PDTA_BitMap,&bm,TAG_END);
if (bm && bmhd)
{
winw = bmhd->bmh_Width + scr->WBorLeft + scr->WBorRight;
winh = bmhd->bmh_Height + scr->WBorTop + scr->RastPort.TxHeight + 1 + scr->WBorBottom;
if (win = OpenWindowTags (NULL,
WA_Left, (scr->Width - winw) / 2,
WA_Top, (scr->Height - winh) / 2,
WA_Width, winw,
WA_Height, winh,
WA_Title, args.file,
WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_ACTIVATE | WFLG_NOCAREREFRESH,
WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY,
TAG_END))
{
rc = RETURN_OK;
BltBitMapRastPort (bm,0,0,win->RPort,win->BorderLeft,win->BorderTop,win->GZZWidth,win->GZZHeight,0xc0);
cont = TRUE;
do {
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);
}
}
else
Printf ("image cannot be rendered into the named pubscreen\n");
DisposeDTObject (dto);
}
else
{
Printf (GetDTString (IoErr()),args.file);
Printf ("\n");
}
UnlockPubScreen (NULL,scr);
}
else
Printf ("cannot lock pubscreen\n");
return (rc);
}
Thats the whole file - someone slid it to me in the effort to clarify my getting a picture into a window. As you can see the #includes are already there. I hope you have some more magic for me beecause all my spells have been spent hours ago.
Thanks:)
-
First of all, you should compile the app with -noixemul.
Additionally the code depends on the library bases being opened automagically so you may need to add libauto (-lauto). Some systems don't have working libauto in which case you need to open the library bases manually as described earlier.
-
First of all, you should compile the app with -noixemul.
Additionally the code depends on the library bases being opened automagically so you may need to add libauto (-lauto). Some systems don't have working libauto in which case you need to open the library bases manually as described earlier.
I was wondering about libauto. By some systems don't have it, do you mean that some compilers don't provide it or do you mean literally that like OS3 might not have it vs. OS 3.1?
-
I was wondering about libauto. By some systems don't have it, do you mean that some compilers don't provide it or do you mean literally that like OS3 might not have it vs. OS 3.1?
It's a link library, so it's down to the compiler to provide it.
Personally, I always manage opening libraries, devices etc. manually.
PS. long time no see!
-
I have really been searching for information or code examples but I have found nothing that explains how to program a picture into an amiga window or screen... PLEASE - someone must have an idea where I can look or offer som sort of code that I can do this with. :furious:
The example I posted has proven to be useless btw.
-
Amiga needs Wine. ;-)
-
The example I posted has proven to be useless btw.
Why? It loads a picture with the Datatypes system and blits it into a window. What do you expect?
-
Why? It loads a picture with the Datatypes system and blits it into a window. What do you expect?
I was hoping it would compile and run so I can learn something. I tried it in 3 compilers GCC , DEVCC, Codeblocks - no luck with all three, though DEVCC had the least amount of errors but I cant decipherthem. Damn.
-
I was hoping it would compile and run so I can learn something. I tried it in 3 compilers GCC , DEVCC, Codeblocks - no luck with all three, though DEVCC had the least amount of errors but I cant decipherthem. Damn.
The example compiles just fine with gcc here if I specify -noixemul. I do have working libauto though. If I leave -noixemul out I get the same errors as you (as expected).
-
Thanks for your input - this is what I am getting:
(http://img546.imageshack.us/img546/250/12627105.png) (http://imageshack.us/photo/my-images/546/12627105.png/)
:confused:
-
problem solved - got help from English Amiga Board.:roflmao: