![]() |
![]() |
#1 |
Sub-Dimensional Array
Join Date: Nov 2011
Location: Australia
Posts: 123
|
How to load an image in C into a window/screen?
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?
![]() |
![]() |
![]() |
#2 | |
Registered User
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
|
Quote:
If you are interested I can upload the source code, it's fairly complicated because it's a program with various options, the main one being it's controllable from Arexx, and you can display any one frame like in a slide show. If you really study the code you can see how to setup the color map and the bit map and then display it. |
|
![]() |
![]() |
#3 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
|
![]() |
![]() |
#4 |
Sub-Dimensional Array
Join Date: Nov 2011
Location: Australia
Posts: 123
|
Thanks thomas but I think your code was written in OS4 - no? A lot of declarations and such are nor found in my C library as it is now.
![]() I would like to try and get this code to compile and then examine its parts. ![]() PDTA_DestMode & PMODE_V43 are the culprits Last edited by Morbane; 04 January 2012 at 22:39. |
![]() |
![]() |
#5 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
You need the OS 3.9 include files or the picture.datatype V43 include files. Or just remove PDTA_DestMode,PMODE_V43 from the statement. Without it the picture will always be dithered to 8 bits or less. V43 mode allows true color bitmaps (16 or 24 bits).
The initialization warnings seem to be specific to GCC. You might need to cast each complained pointer to (ULONG). I don't know what MUIPictureClass ist but I suppose that it certainly needs MUI include files. |
![]() |
![]() |
#6 |
Zone Friend
Join Date: Jan 2005
Location: italy
Age: 46
Posts: 244
|
@thomas
i've watched your sources, but i have a problem...... my function is this : struct Bitmap *bm_load_(char* name) { struct Bitmap *TEMPbitmap = NULL; Object *dtype = NULL; struct BitMapHeader *bmh = NULL; int result; dtype = NewDTObject(name, DTA_GroupID,GID_PICTURE, PDTA_DestMode, PMODE_V43, PDTA_Remap, FALSE, TAG_END); if (dtype == NULL) printf("immagine non caricata\n"); result = GetDTAttrs(dtype, PDTA_BitMapHeader, (ULONG)&bmh, TAG_END); if (result != 1) printf("impossibile ottenere info sull'immagine\n"); TEMPbitmap = calloc(1,sizeof(Bitmap)); TEMPbitmap->width = bmh->bmh_Width; TEMPbitmap->height = bmh->bmh_Height; TEMPbitmap->depth = bmh->bmh_Depth; // per ora non viene usato if(DoDTMethod (dtype,NULL,NULL,DTM_PROCLAYOUT,NULL,TRUE)){ result = GetDTAttrs(dtype, PDTA_DestBitMap, (ULONG)&TEMPbitmap->bitmap, PDTA_NumColors, (ULONG)&TEMPbitmap->colorNumber, PDTA_CRegs, (ULONG)&TEMPbitmap->colorRegisters, TAG_DONE); if (result <3 ) printf("caricamento immagine non riuscita\n"); } TEMPbitmap->palette = adaptCmap(TEMPbitmap->colorNumber, TEMPbitmap->colorRegisters); TEMPbitmap->rastPort = (struct RastPort*) malloc(sizeof(struct RastPort)); InitRastPort(TEMPbitmap->rastPort); TEMPbitmap->rastPort->BitMap = TEMPbitmap->bitmap; // DisposeDTObject (dtype); return TEMPbitmap; } in another function i display the bitmap and all goes good so far but if before the : return TEMPbitmap; } i don't comment off // DisposeDTObject (dtype); the display of the image is garbled. Why? with my function i obtain from the datatype the bitmap+colormap, why i can't dispose the datatype before the visualization? |
![]() |
![]() |
#7 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
DisposeDTObject releases all memory which was allocated by NewDTObject. This includes the bitmap header, the palette and especially the dest bitmap.
If you want to keep the bitmap data after DisposeDTObject you need to copy the entire bitmap and not only the pointer. Here is an example function to create a copy of a bitmap: Code:
struct BitMap *copy_bitmap (struct BitMap *oldbm) { struct BitMap *newbm; long w,h; if (newbm = AllocBitMap ( w = GetBitMapAttr(oldbm,BMA_WIDTH), h = GetBitMapAttr(oldbm,BMA_HEIGHT), GetBitMapAttr(oldbm,BMA_DEPTH), GetBitMapAttr(oldbm,BMA_FLAGS), oldbm)) { BltBitMap (oldbm,0,0,newbm,0,0,w,h,0x0c0,0xff,NULL); } return (newbm); } |
![]() |
![]() |
#8 | |
Zone Friend
Join Date: Jan 2005
Location: italy
Age: 46
Posts: 244
|
Quote:
![]() |
|
![]() |
![]() |
#9 | |
Sub-Dimensional Array
Join Date: Nov 2011
Location: Australia
Posts: 123
|
Quote:
![]() How do I find said OS 3.9 and install it? Did a google search but no info of use came up - at least not in an obvious way. Thanks. |
|
![]() |
![]() |
#10 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
|
![]() |
![]() |
#11 |
Sub-Dimensional Array
Join Date: Nov 2011
Location: Australia
Posts: 123
|
Anyone have an idea that works? Also I have no idea what to do with PictDT43?? I want to think that all I need to do is copy the folder and files to the right place - but where that place is , I have no idea.
SO now I have NDK39.lha - but what to do with it - once it is unpacked??? ![]() Last edited by Morbane; 06 January 2012 at 08:39. |
![]() |
![]() |
#12 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
I told you that you need either the include files from OS 3.9 or the include files from picture.datatype version 43. The former is the Native Developer Kit for AmigaOS 3.9 which contains all include files and documentation for this version of the operating system and the latter is the official picture.datatype V43 archive which contains the include file with the V43 extensions.
The OS 3.9 include files are located in drawer NDK_3.9/Includes/includes_h. I would suspose that it's as easy as to copy them to the os-includes directory of your ADE (Amiga Development Environment). But I cannot tell, I never used GCC. |
![]() |
![]() |
#13 |
Sub-Dimensional Array
Join Date: Nov 2011
Location: Australia
Posts: 123
|
|
![]() |
![]() |
#14 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
Try to compile with -lauto.
|
![]() |
![]() |
#15 |
Sub-Dimensional Array
Join Date: Nov 2011
Location: Australia
Posts: 123
|
|
![]() |
![]() |
#16 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
I think there exists a libtoa utility which can make a libauto.a file from the auto.lib file which is contained in the NDK. Most Amiga compilers can deal with .lib files directly. Only GCC needs .a type files (and no, it is not just a matter of renaming the files).
You should learn to distinguish between compiler and linker errors and you should know that .h files are for the compiler while unresolved references are thrown by the linker. And as an Amiga programmer you should know what xxxBase variables are for and how to use them. You can either define them explicitely in your code and then need to OpenLiberary() each one or you can define them as unresolved external references like it is done in the proto/xxx.h files and need then to link with the auto library. If there is no auto library for your compiler, you need to revert to the OpenLibrary method. Don't expect help with this. Read the libraries section of the RKRM (Rom Kernel Reference Manual). |
![]() |
![]() |
#17 | |
Sub-Dimensional Array
Join Date: Nov 2011
Location: Australia
Posts: 123
|
Quote:
![]() |
|
![]() |
![]() |
#18 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
If you don't invest any work into learning, then I do not feel good in helping you.
If you told me that you read this and that section of a manual and then put together some piece of code and need a little help in compiling it or something, then I am happy to help you. But if you come here saying "I know nothing, please tell me everything", then you let me work for you and you do nothing. That's not what I understand of helping you to learn, because you learn nothing from it. Then you just put together toy blocks and never understand why they fit together or don't fit. |
![]() |
![]() |
#19 |
Sub-Dimensional Array
Join Date: Nov 2011
Location: Australia
Posts: 123
|
Fair enough - would you happen to have a link to a copy of the Rom Kernel Reference Manual?? I looked around and could not find one - but I am beginning to think it is too recent of a publication that it be free on pdf - I just thought I would ask.
|
![]() |
![]() |
#20 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,030
|
I don't think there are PDF versions available. You can either buy the books or the developer CD which contains the RKRMs as AmigaGuide documents. http://www.vesalia.de/e_developer2.htm
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Black screen in full screen but not full window Winuae all versions | Mixter | support.WinUAE | 18 | 30 June 2013 00:45 |
[Bug] Screen doesn't update in 32-bit window | RealNC | support.WinUAE | 2 | 25 August 2007 10:43 |
Window doesnt fit the screen??? | richeyjh | support.WinFellow | 4 | 04 July 2005 20:17 |
Winuae 0.8.26 Hangs when load disk image | Unregistered | support.WinUAE | 10 | 04 June 2004 00:36 |
Window to Full Screen | Nyarlathotep | support.WinUAE | 4 | 14 January 2003 23:09 |
|
|