Hi All,
Following the last message concerning DataTypes, I manage to have my images loaded and everything work perfectly, images are ok on screen and on 3D objects but.... Because there is always "but" somewhere ... I get random DSI error ...
When I choose "ignore DSI errors", the program run perfectly and all images are displayed on screen like they should. Showing they are loaded ...
So, what's wrong ? I didn't find why ...
Here is the code :
#include <stdlib.h>
#include <stdio.h>
// #include <amiga-align.h>
#include <datatypes/datatypes.h>
#include <datatypes/pictureclass.h>
#include <clib/alib_protos.h>
#include <proto/datatypes.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
// #include <cybergraphx/cybergraphics.h>
// #include <proto/cybergraphics.h>
// #include <default-align.h>
#include <exec/memory.h>
// struct IntuitionBase *MyIntuitionBase;
// struct GfxBase *GfxBase;
// struct Library *CyberGfxBase;
struct Library *DataTypesBase;
struct DataTypesIFace * IDataTypes = 0;
/*
struct MyPicture{
int Width;
int Height;
int Depth;
unsigned char *Pixels;
};
*/
struct MyPicture * AllocPicture( int Width, int Height, int Depth ){
struct MyPicture *pt = NULL;
int Bytes;
Bytes = Depth / 8;
pt = (struct MyPicture *)IExec->AllocVec( sizeof( struct MyPicture ), MEMF_ANY|MEMF_CLEAR );
if ( pt ){
pt->Pixels = IExec->AllocVec( Width * Height * Bytes, MEMF_ANY );
pt->Width = Width;
pt->Height = Height;
pt->Depth = Depth;
if ( pt->Pixels == NULL ){
IExec->FreeVec( pt );
pt = NULL;
}
}
return pt;
}
void FreePicture( struct MyPicture *pt ){
if ( pt ){
IExec->FreeVec( pt->Pixels );
pt->Pixels = NULL;
IExec->FreeVec( pt );
}
}
struct MyPicture * LoadPicture( APTR FileName, int Alpha ){
struct MyPicture *pt = NULL;
Object *dto = NULL;
ULONG nb;
struct BitMapHeader *bmh = NULL;
struct pdtBlitPixelArray bpa;
void * bpaptr = &bpa;
if ( !FileName ) return NULL;
DataTypesBase = IExec->OpenLibrary( "datatypes.library", 43 );
if ( DataTypesBase ){
IDataTypes = ( struct DataTypesIFace *)IExec->GetInterface( DataTypesBase, "main", 1, NULL );
if ( IDataTypes != 0 ){
dto = ( Object *)IDataTypes->NewDTObject( (STRPTR)FileName, DTA_GroupID, GID_PICTURE,
PDTA_DestMode, PMODE_V43, PDTA_Remap,
FALSE, TAG_DONE );
if ( dto ){
nb = IDataTypes->GetDTAttrs( dto, PDTA_BitMapHeader, &bmh, TAG_DONE );
// nb = IIntuition->GetAttr( PDTA_BitMapHeader, dto, &bmh );
if( nb != 0 ){
int resread;
printf( "Sizes: %dx%dx%d\n", bmh->bmh_Width, bmh->bmh_Height, bmh->bmh_Depth );
/* Allocation de la structure Picture et du buffer m?moire */
pt = AllocPicture( bmh->bmh_Width, bmh->bmh_Height, 32 );
if ( pt != NULL ){
bpa.MethodID = PDTM_READPIXELARRAY;
bpa.pbpa_PixelData = pt->Pixels;
bpa.pbpa_PixelFormat = Alpha?PBPAFMT_RGBA:PBPAFMT_RGB;
bpa.pbpa_PixelArrayMod = bmh->bmh_Width * 4;
bpa.pbpa_Left = 0;
bpa.pbpa_Top = 0;
bpa.pbpa_Width = bmh->bmh_Width;
bpa.pbpa_Height = bmh->bmh_Height;
resread = IIntuition->IDoMethodA( dto, bpaptr );
// resread = IDataTypes->DoDTMethodA( dto, 0, 0, bpaptr );
}else{
printf( "Cannot allocate memory for mypicture structure\n" );
}
}else{
printf( "Impossible to read image data informations\n" );
}
IDataTypes->DisposeDTObject( dto );
}else{
printf( "Unable to load file\n" );
}
IExec->DropInterface( ( struct Interface * )IDataTypes );
}else{
printf( "DataType interface cannot be opened" );
}
IExec->CloseLibrary( DataTypesBase );
}else{
printf( "impossible to open datatypes.library ver 43+\n" );
}
return pt;
}
As you can see in the source code, I tried both Intuition and Datatypes funcions to get Objects attributes and to do method ... Same result ...
EDIT :
Apparently the crash came from MiniGL.library and not from DataTypes as I can see in the crash log file :
"Crash occured in module minigl.library at address 0x6F5C2384"
Symbol Info :
Instruction pointer 0x6F5C23B4 belongs to module "minigl.library" (HUNK/Kickstart)
Hope someone already experienced this and can help :)
EDIT :
After some tests, I suspect WarpPNG is faulty because if I change the WarpDT prefs, I get other issues with images and DSI errors ...
Regards,
AmiDARK.
Edited by freddix on 2010/8/30 21:35:46
Edited by freddix on 2010/8/30 22:44:43
Edited by freddix on 2010/8/31 9:00:10