Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
162 user(s) are online (102 user(s) are browsing Forums)

Members: 0
Guests: 162

more...

Headlines

 
  Register To Post  

(1) 2 »
[Fixed]Use datatypes.library to open/load images/sounds
Quite a regular
Quite a regular


See User information
Hi,

Can someone help me to understand how I can use the datatypes.library to open/load images & sounds in memory and recognize them (to know what it is, ex jpg, bmp, png, raw, iff, mp3, wav, ogg, etc ...)

Thank you to all peoples that helped me for DataTYPES.

Here is the functions that now work perfectly under Amiga OS 4.1u2:
(Corto, you can put it in your tutorial page if you want)

#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 AllocPictureint Widthint Heightint Depth ){
  
struct MyPicture *pt NULL;
  
int Bytes;
  
Bytes Depth 8;
  
pt = (struct MyPicture *)IExec->AllocVecsizeofstruct MyPicture ), MEMF_ANY|MEMF_CLEAR );
  if ( 
pt ){
    
pt->Pixels IExec->AllocVecWidth Height BytesMEMF_ANY );
    
pt->Width Width;
    
pt->Height Height;
    
pt->Depth Depth;

    if ( 
pt->Pixels == NULL ){
      
IExec->FreeVecpt );
      
pt NULL;
     }
   }
  return 
pt;
 }

void FreePicturestruct MyPicture *pt ){
  if ( 
pt ){
    
IExec->FreeVecpt->Pixels );
    
pt->Pixels NULL;
    
IExec->FreeVecpt );
   }
 }

struct MyPicture LoadPictureAPTR FileNameint 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->GetInterfaceDataTypesBase"main"1NULL );
   if ( 
IDataTypes != ){
     
dto = ( Object *)IDataTypes->NewDTObjectFileNameDTA_GroupIDGID_PICTUREPDTA_DestModePMODE_V43TAG_DONE );
      if ( 
dto ){
        
nb IDataTypes->GetDTAttrsdtoPDTA_BitMapHeader, (ULONG)&bmhTAG_DONE );
        if( 
nb == ){
          
int resread;
          
printf"Dimensions : %dx%dx%d\n"bmh->bmh_Widthbmh->bmh_Heightbmh->bmh_Depth );
          
/* Allocation de la structure Picture et du buffer m?moire */
          
pt AllocPicturebmh->bmh_Widthbmh->bmh_Height, ( Alpha ) * );
          if ( 
pt ){
            
bpa.MethodID PDTM_READPIXELARRAY;
            
bpa.pbpa_PixelData pt->Pixels;
            
bpa.pbpa_PixelFormat Alpha?PBPAFMT_RGBA:PBPAFMT_RGB;
            
bpa.pbpa_PixelArrayMod bmh->bmh_Width * ( Alpha );
            
bpa.pbpa_Left 0;
            
bpa.pbpa_Top 0;
            
bpa.pbpa_Width bmh->bmh_Width;
            
bpa.pbpa_Height bmh->bmh_Height;
            
resread IIntuition->IDoMethodAdtobpaptr );
            
printf"Image Loaded size : %08i\n", ( Alpha ) * );
           }else{
            
printf"Impossible d'allouer de la m?moire pour la structure Picture\n" );
           }
         }else{
          
printf"Impossible de lire les informations de l'image\n" );
         }
        
IDataTypes->DisposeDTObjectdto );
       }else{
        
printf"Echec dans le chargement du fichier\n" );
       }
     }else{
      
printf"Echec dans l'ouverture de l'interface DataTypes" );
     }
    
IExec->CloseLibraryDataTypesBase );
   }else{
    
printf"Impossible d'ouvrir la datatypes.library ver 43+\n" );
   }
  return 
pt;
 }


Kindest Regards,
AmiDARK.


Edited by freddix on 2010/8/30 17:35:37
All we have to decide is what to do with the time that is given to us.
Go to top
Re: Use datatypes.library to open/load images/sounds
Home away from home
Home away from home


See User information
@freddix
You might have more luck on utilitybase.com althought datatypes are a bit of a black art, due to lack of documentation (your best bet is finding some code that does what you want).

Author of the PortablE programming language.
Go to top
Re: Use datatypes.library to open/load images/sounds
Just can't stay away
Just can't stay away


See User information
@freddix

#include <datatypes/datatypes.h>
#include <datatypes/pictureclass.h>
#include <proto/datatypes.h>

struct Library *DataTypesBase=0;
struct DataTypesIFace *IDataTypes=0;
APTR DTFile=0;
struct BitMap *bm=0;

DataTypesBase=(struct Library *)IExec->OpenLibrary("datatypes.library",52);
if (DataTypesBase!=0)
{
IDataTypes=(struct DataTypesIFace *)IExec->GetInterface(DataTypesBase,"main",1,NULL);
if (IDataTypes!=0)
{
DTFile=IDataTypes->NewDTObject("file_name",
DTA_GroupID,GID_PICTURE,
PDTA_DestMode,PMODE_V43,
TAG_DONE);
if (DTFile!=0)
{
IDataTypes->GetDTAttrs(DTFile,PDTA_BitMap,&bm,TAG_DONE);
// bm points to a bitmap containing the picture
if (bm!=0)
{
} /* if */
IDataTypes->DisposeDTObject(DTFile); DTFile=0; bm=0;
} /* if */
else ;
IExec->DropInterface((struct Interface *)IDataTypes);
} /* if */
else printf("ERROR: Can't open datatypes main interface\n");
IExec->CloseLibrary(DataTypesBase);
} /* if */
else printf("ERROR: Can't open datatypes.library v52\n");


Edited by TSK on 2010/8/27 16:18:52
Rock lobster bit me - so I'm here forever
X1000 + AmigaOS 4.1 FE
"Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Go to top
Re: Use datatypes.library to open/load images/sounds
Amigans Defender
Amigans Defender


See User information
@freddix

It depends entirely on what you want to do. If you are opening a file and know the base class it is, you just need:

Object *dto;
        if(
dto NewDTObject(filenameDTA_GroupIDGID_TEXTTAG_DONE))
  
DisposeDTObvject(dto);


The DTA_GroupID tag ensure that the file is of that type. Otherwise you'll get problems later when you try to read data.

You'll need to use GetDTAttrs or call some methods before DisposeDTObject, if you want to do anything useful.

If you merely want to find out what filetype a file is, you need something like:

struct DataTypeHeader *dth NULL;
    
struct DataType *dtn;

    if (
dtn ObtainDataTypeA (DTST_FILE, (APTR)lockNULL)) {
     
dth dtn->dtn_Header;
 
printf("Group: %s\n",dth->dth_GroupID);
 
printf("BaseName: %s\n",dth->dth_BaseName);
     
ReleaseDataType(dtn);
}


You can then open the file and handle it as per the base type dth_GroupID.

Check the AutoDocs for datatypes.library AND the AutoDocs for the base classes (picture_dtc etc) to find out how to get data out of them. If you have any more specific questions ask here or UtilityBase (UtilityBase is usually a better place for programming questions)

Go to top
Re: Use datatypes.library to open/load images/sounds
Not too shy to talk
Not too shy to talk


See User information
@freddix

I don't know what you need exactly :

- load images and sounds
I never tried with sounds but you can read the articles I wrote in french about pictures here on gurumed.net

- get the initial format name
I don't know why (datatypes goal is to add an abstraction layer) but in my opinion, you will certainly be forced to read the header of the file and identify it manually.

Go to top
Re: Use datatypes.library to open/load images/sounds
Quite a regular
Quite a regular


See User information
@corto
Quote:
I don't know why (datatypes goal is to add an abstraction layer) but in my opinion, you will certainly be forced to read the header of the file and identify it manually.

It's what I planed to do ;)

@Corto & Others : Thank you for these informations.
Will check all of these tomorrow :p

Kindest Regards,
AmiDARK.

All we have to decide is what to do with the time that is given to us.
Go to top
Re: Use datatypes.library to open/load images/sounds
Home away from home
Home away from home


See User information
@freddix

IIRC, the current sound datatype can't handle anything better than 8-bit stereo sound. Someone made a new one that was much more flexible, but I don't think that it was ever adopted as standard (it's on os4depot, IIRC).

Datatypes is yet another area that could use an overhaul. Streaming data, generating thumbnails, etc., and most importantly, and easier to use API.

Hans

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
Go to top
Re: Use datatypes.library to open/load images/sounds
Quite a regular
Quite a regular


See User information
@Hans
In fact, I took a "fast" look at what friends sent upper.
I've found that Corto sample :
http://www.gurumed.net/index.php/R%C3 ... ge_en_tant_que_buffer_RGB
if exactly what I need ( load an image in memory ).
More to this, Corto is French like me so it's easier for me to learn from this sample.

I'll keep your advice concerning audio in mind before doing any tests concerning audio.

Kindest Regards,
AmiDARK.

All we have to decide is what to do with the time that is given to us.
Go to top
Re: Use datatypes.library to open/load images/sounds
Amigans Defender
Amigans Defender


See User information
@Hans

Quote:

IIRC, the current sound datatype can't handle anything better than 8-bit stereo sound.


That's not true any more, it has supported 16-bit sound since OS4.1u1.

Quote:

Datatypes is yet another area that could use an overhaul. Streaming data, generating thumbnails, etc., and most importantly, and easier to use API.


It needs a bit of an update in some areas, but nothing too major. It would be nice if more apps supported them - pictures are well supported, sounds less so, and anything else gets no support from apps whatsoever (actually NetSurf supports reading text through Datatypes in specific circumstances - first app other than Multiview that I know of able to use text datatypes). Text datatypes really do need an update - although IFF FTXT is supposed to be Formatted TeXT, there's very little formatting apparently supported, and this impacts what can be put on the clipboard too (copying a table with all the formatting intact is impossible).

It's worth chucking a quick mention of my drawing.datatype OA project in here: http://www.openamiga.org/?function=viewproject&projectid=51

It's making slow progress, but that's better than no progress.

Chris

Go to top
Re: Use datatypes.library to open/load images/sounds
Home away from home
Home away from home


See User information
@Chris

Quote:

Chris wrote:
@Hans

Quote:

IIRC, the current sound datatype can't handle anything better than 8-bit stereo sound.


That's not true any more, it has supported 16-bit sound since OS4.1u1.


Oh, I didn't know that. I'm going to have to take a closer look at that. I still have that unfinished animation datatype project sitting on my hard-drive. No time to work on it though.

Hans

http://hdrlab.org.nz/ - Amiga OS 4 projects, programming articles and more.
https://keasigmadelta.com/ - more of my work
Go to top
Re: Use datatypes.library to open/load images/sounds
Supreme Council
Supreme Council


See User information
@Chris

Quote:

(actually NetSurf supports reading text through Datatypes in specific circumstances - first app other than Multiview that I know of able to use text datatypes).


CodeBench uses the text.datatype too.

Simon

Comments made in any post are personal opinion, and are in no-way representative of any commercial entity unless specifically stated as such.
----
http://codebench.co.uk
Go to top
Re: Use datatypes.library to open/load images/sounds
Just can't stay away
Just can't stay away


See User information
@Chris

Quote:

That's not true any more, it has supported 16-bit sound since OS4.1u1.


I had no idea that there was a new sound.datatype in 4.1 update 1.

Just looked in datatypes/soundclass.h and found this:
/* (UBYTE) The actual bitrate of the sample. 8, 16 or 32. New in 53.2 */
#define SDTA_BitsPerSample (SDTA_Dummy + 18)

Looks like I have some datatypes to update.

Go to top
Re: Use datatypes.library to open/load images/sounds
Quite a regular
Quite a regular


See User information
@Chris : Thank you for these "precision" ;)

@salass00
Update ! Update ! ;) and Upload ! Upload ! loooool :p

Whatever, I have what I need now.
Thank you all for your comments and help.

Kindest Regards,
AmiDARK.

All we have to decide is what to do with the time that is given to us.
Go to top
Re: Use datatypes.library to open/load images/sounds
Quite a regular
Quite a regular


See User information
@freddix
I tried this :
Quote:
#include <stdlib.h>
#include <stdio.h>

// #include <amiga-align.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>

// struct IntuitionBase *MyIntuitionBase;
// struct GfxBase *GfxBase;
// struct Library *CyberGfxBase;
struct Library *DataTypesBase;

struct MyPicture{
int Width;
int Height;
int Depth;
unsigned char *Pixels;
};

struct Picture * AllocPicture( int Width, int Height, int Depth ){
struct MyPicture *pt = NULL;
int Bytes;
Bytes = ( Depth + 7 ) / 8;
pt = 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 Picture * LoadPicture( STRPTR FileName, int Alpha ){
struct MyPicture *pt = NULL;
Object *dto = NULL;
ULONG nb;
struct BitMapHeader *bmh;
struct pdtBlitPixelArray bpa;

if ( !FileName ) return NULL;

DataTypesBase = IExec->OpenLibrary( "datatypes.library", 43 );
if ( DataTypesBase ){
dto = IDataTypes->NewDTObject( FileName, DTA_GroupID, GID_PICTURE,
PDTA_DestMode, PMODE_V43,
PDTA_Remap, FALSE,
TAG_END );
if ( dto ){
nb = IDataTypes->GetDTAttrs( dto, PDTA_BitMapHeader, (ULONG)&bmh,
TAG_END );
if( nb == 1 ){
int resread;
printf( "Dimensions : %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, ( 3 + Alpha ) * 8 );
if ( pt ){
bpa.MethodID = PDTM_READPIXELARRAY;
bpa.pbpa_PixelData = pt->Pixels;
bpa.pbpa_PixelFormat = Alpha?PBPAFMT_RGBA:PBPAFMT_RGB;
bpa.pbpa_PixelArrayMod = bmh->bmh_Width * ( 3 + Alpha );
bpa.pbpa_Left = 0;
bpa.pbpa_Top = 0;
bpa.pbpa_Width = bmh->bmh_Width;
bpa.pbpa_Height = bmh->bmh_Height;
resread = IDataTypes->DoDTMethodA( dto, (Msg)&bpa );
}else{
printf( "Impossible d'allouer de la m?moire pour la structure Picture\n" );
}
}else{
printf( "Impossible de lire les informations de l'image\n" );
}
IDataTypes->DisposeDTObject( dto );
}else{
printf( "Echec dans le chargement du fichier\n" );
}
IExec->CloseLibrary( DataTypesBase );
}else{
printf( "Impossible d'ouvrir la datatypes.library ver 43+\n" );
}
return pt;
}

And when I compile, I get this error :
Quote:
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c: In function 'AllocPicture':
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:44: warning: return from incompatible pointer type
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c: In function 'LoadPicture':
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:77: warning: assignment from incompatible pointer type
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:87: warning: dereferencing type-punned pointer will break strict-aliasing rules
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:87: warning: passing argument 3 of 'IDataTypes->DoDTMethodA' from incompatible pointer type
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:87: error: too few arguments to function 'IDataTypes->DoDTMethodA'
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:102: warning: return from incompatible pointer type


I've checked the DoDTMethodA and it need more arg:
ULONG DoDTMethodA( Object *, struct Window *, struct Requester *, Msg/Data )
Why Requester ?

I tried to modify with this :
Quote:
void * NullWindow = NULL;
void * NullRequester = NULL;
resread = IDataTypes->DoDTMethodA( dto, NullWindow, NullRequester, (Msg)&bpa);


And now, I get this :
Quote:
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c: In function 'AllocPicture':
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:44: warning: return from incompatible pointer type
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c: In function 'LoadPicture':
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:80: warning: assignment from incompatible pointer type
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:90: warning: dereferencing type-punned pointer will break strict-aliasing rules
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:105: warning: return from incompatible pointer type
AmiDE_3D.c: At top level:
AmiDARK:Shared/Sound/Sound.c:15: warning: 'DELoadSound' defined but not used
AmiDARK:Shared/Sound/Sound.c:45: warning: 'DEDeleteSound' defined but not used
gcc -mcrt=newlib -O3 -Wall -gstabs -DMINIGL -o AmiDE_3D.exe.debug AmiDE_3D.o -lm -lGL -lGLUT -lglpng -lpng -lz
AmiDE_3D.o: In function `LoadPicture':
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:69: undefined reference to `IDataTypes'
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:69: undefined reference to `IDataTypes'
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:74: undefined reference to `IDataTypes'
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:97: undefined reference to `IDataTypes'
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:90: undefined reference to `IDataTypes'
make: *** [AmiDE_3D.exe] Error 1


Why ?

Regards,
AmiDARK.

All we have to decide is what to do with the time that is given to us.
Go to top
Re: Use datatypes.library to open/load images/sounds
Quite a regular
Quite a regular


See User information
@Chris

Quote:
[b]It's worth chucking a quick mention of my drawing.datatype OA project in here: http://www.openamiga.org/?function=viewproject&projectid=51

That will be so useful. I scan kanji , and edit them in ImageFX to remove the stroke numbers etc, and use BME to convert to dr2d to use them in pagestream.
It would be very useful to view them via multiview instead of having to load them inro pagestream, or Drawstudio to view them.

Peter Swallow

Eyetech A1XE-G3 800Mhz OS4.1
Towered A1200 OS3.9
Go to top
Re: Use datatypes.library to open/load images/sounds
Just can't stay away
Just can't stay away


See User information
@freddix

You have to do type casting. For example:

pt = (struct MyPicture *)IExec->AllocVec( sizeof( struct MyPicture ), MEMF_ANY|MEMF_CLEAR );

dto = (Object *)IDataTypes->NewDTObject( FileName, DTA_GroupID, GID_PICTURE,

Also you haven't opened the interface of the datatypes library. You have to open it too. IDataTypes is not defined and opened in your program. Check my example earlier in this thread.

You can give null to struct Requester *.

Rock lobster bit me - so I'm here forever
X1000 + AmigaOS 4.1 FE
"Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Go to top
Re: Use datatypes.library to open/load images/sounds
Just can't stay away
Just can't stay away


See User information
@freddix
Quote:
Why?

Because it's OS3 code? I don't know where I got it, but I found the same code in my programming examples directory with OS4 specific additions to make it compile for OS4. The errors you see seem to be more related to OS4 interfaces than bugs in the code. Maybe someone else will recognize the code and tell us where the OS4 version is located.

Go to top
Re: Use datatypes.library to open/load images/sounds
Quite a regular
Quite a regular


See User information
@TSK :
I've made changes with your advices and get now this file :

#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 AllocPictureint Widthint Heightint Depth ){
  
struct MyPicture *pt NULL;
  
int Bytes;
  
Bytes = ( Depth ) / 8;
  
pt = (struct MyPicture *)IExec->AllocVecsizeofstruct MyPicture ), MEMF_ANY|MEMF_CLEAR );
  if ( 
pt ){
    
pt->Pixels IExec->AllocVecWidth Height BytesMEMF_ANY );
    
pt->Width Width;
    
pt->Height Height;
    
pt->Depth Depth;

    if ( 
pt->Pixels == NULL ){
      
IExec->FreeVecpt );
      
pt NULL;
     }
   }
  return 
pt;
 }

void FreePicturestruct MyPicture *pt ){
  if ( 
pt ){
    
IExec->FreeVecpt->Pixels );
    
pt->Pixels NULL;
    
IExec->FreeVecpt );
   }
 }

struct MyPicture LoadPictureAPTR FileNameint Alpha ){
  
struct MyPicture *pt NULL;
  
Object *dto NULL;
  
ULONG nb;
  
struct BitMapHeader *bmh NULL;
  
struct pdtBlitPixelArray bpa;
  
void NullStructPTR NULL;

  if ( !
FileName ) return NULL;

  
DataTypesBase IExec->OpenLibrary"datatypes.library"43 );
  if ( 
DataTypesBase ){
   
IDataTypes = ( struct DataTypesIFace *)IExec->GetInterfaceDataTypesBase"main"1NULL );
   if ( 
IDataTypes != ){
     
dto = ( Object *)IDataTypes->NewDTObjectFileNameDTA_GroupIDGID_PICTUREPDTA_DestModePMODE_V43TAG_DONE );
      if ( 
dto ){
        
nb IDataTypes->GetDTAttrsdtoPDTA_BitMapHeader, (ULONG)&bmhTAG_DONE );
        if( 
nb == ){
          
int resread;
          
printf"Dimensions : %dx%dx%d\n"bmh->bmh_Widthbmh->bmh_Heightbmh->bmh_Depth );
          
/* Allocation de la structure Picture et du buffer m?moire */
          
pt AllocPicturebmh->bmh_Widthbmh->bmh_Height, ( Alpha ) * );
          if ( 
pt ){
            
bpa.MethodID PDTM_READPIXELARRAY;
            
bpa.pbpa_PixelData pt->Pixels;
            
bpa.pbpa_PixelFormat Alpha?PBPAFMT_RGBA:PBPAFMT_RGB;
            
bpa.pbpa_PixelArrayMod bmh->bmh_Width * ( Alpha );
            
bpa.pbpa_Left 0;
            
bpa.pbpa_Top 0;
            
bpa.pbpa_Width bmh->bmh_Width;
            
bpa.pbpa_Height bmh->bmh_Height;
//            resread = IDataTypes->DoDTMethodA( dto, NullWindow, NullRequester, (Msg)&bpa );
            
resread IDataTypes->DoDTMethoddtoNullStructPTRNullStructPTR, (Msg)&bpa );
           }else{
            
printf"Impossible d'allouer de la m?moire pour la structure Picture\n" );
           }
         }else{
          
printf"Impossible de lire les informations de l'image\n" );
         }
        
IDataTypes->DisposeDTObjectdto );
       }else{
        
printf"Echec dans le chargement du fichier\n" );
       }
     }else{
      
printf"Echec dans l'ouverture de l'interface DataTypes" );
     }
    
IExec->CloseLibraryDataTypesBase );
   }else{
    
printf"Impossible d'ouvrir la datatypes.library ver 43+\n" );
   }
  return 
pt;
 }


And now, program compiles but I get a warning that stress me a bit. Can someone enlight this problem ?

Quote:
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c: In function 'LoadPicture':
AmiDARK:Shared/AmigaOS4/AmigaOS_DataTypes.c:91: warning: dereferencing type-punned pointer will break strict-aliasing rules


It concern this line of code :
Quote:
resread = IDataTypes->DoDTMethod( dto, NullStructPTR, NullStructPTR, (Msg)&bpa );

Same if I change with this :
Quote:
resread = IDataTypes->DoDTMethodA( dto, NullStructPTR, NullStructPTR, (Msg)&bpa );


EDIT :
More to this, as additional note.. My GCC crash at compilation 1 times on 2.. I can compile it once and then if I try to compile it again, GCC crash with an ISI error ( Instruction Storage Error ) and gream reaper ... If I do a "soft reset". it crash at 1st compilation. If I turn off and on Amiga. I can compile one and after next one crash.

All we have to decide is what to do with the time that is given to us.
Go to top
Re: Use datatypes.library to open/load images/sounds
Just popping in
Just popping in


See User information
@thread

Just a thought- . update datatype system for text with a small parser. This way any text format can be used.

text = LoadDataType(FileName, DataType.Text, "AmigaGuide");

SaveDataType(FileName, text, DataType.Text, "XML", USEPARSER);

AmigaGuide -> XML

Go to top
Re: Use datatypes.library to open/load images/sounds
Not too shy to talk
Not too shy to talk


See User information
Quote:

Hans wrote:

Someone made a new one that was much more flexible, but I don't think that it was ever adopted as standard (it's on os4depot, IIRC).


I talked about shared objects around SDL_image, here is another example of what could be consolidated.

Quote:
Datatypes is yet another area that could use an overhaul. Streaming data, generating thumbnails, etc., and most importantly, and easier to use API.

Hans


I fully agree, I wrote articles to understand details about datatypes. I only explored pictures and it took many hours and several articles.
The concept is great but the implementation suffers of legacy ...

Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project