Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
124 user(s) are online (70 user(s) are browsing Forums)

Members: 1
Guests: 123

kikems, more...

Support us!

Headlines

 
  Register To Post  

« 1 (2)
Re: Use datatypes.library to open/load images/sounds
Just can't stay away
Just can't stay away


See User information
@freddix

Quote:
resread = IDataTypes->DoDTMethod( dto, NullStructPTR, NullStructPTR, (Msg)&bpa );

Why do you use NullStructPTR variable (pointer) there ? Use null directly:
resread = IDataTypes->DoDTMethod( dto, 0, 0, (Msg)&bpa );

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
Quite a regular
Quite a regular


See User information
@TSK
Same Warning.
I think it's related to the (msg)&bpa

EDIT:
Fixed using this ptr casting :p :
struct pdtBlitPixelArray bpa;
void * bpaptr = &bpa;
...
resread = IDataTypes->DoDTMethod( dto, 0, 0, (Msg*)bpaptr );
...

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
Hi All,

I used the Corto sample on how to use DataType on Amiga OS 3.x and adapted with the help of amigans.net users on Amiga OS 4.
Corto tutorial : http://www.gurumed.net/index.php/R%C3 ... ge_en_tant_que_buffer_RGB

Now, I can compile it, it run but I get a grim reaper and if I tell him to continue, images are not loaded correctly in memory and graphics get stranges.

Here is the DataType loader functions :
#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( FileName, DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, TAG_DONE );
      if ( 
dto ){
        
nb = IDataTypes->GetDTAttrs( dto, PDTA_BitMapHeader, (ULONG)&bmh, TAG_DONE );
        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, NullWindow, NullRequester, (Msg)&bpa );
            
resread = IDataTypes->DoDTMethod( dto, 0, 0, (Msg*)bpaptr );
            
printf( "Image Loaded size : %08i\n", ( 3 + Alpha ) * 8 );
           }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" );
       }
     }else{
      
printf( "Echec dans l'ouverture de l'interface DataTypes" );
     }
    
IExec->CloseLibrary( DataTypesBase );
   }else{
    
printf( "Impossible d'ouvrir la datatypes.library ver 43+\n" );
   }
  return 
pt;
 }


The objective is that the "struct MyPicture * LoadPicture( APTR FileName, int Alpha )" function load image using datatype and uncompress it in memory as RGBA32 or ARGB32 buffer.

EDIT : I have modifiers DoDTMethod with doDTMethodA and I get a warning for incompatible pointer type as arg #5.
I have then modified the line with :
resread = IDataTypes->DoDTMethodA( dto, 0, 0, (Msg)bpa );

Now it compiles with no warning but it crash when running DoDTMethodA ...

Anyone have any clue ?

Kindest Regards,
AmiDARK.

All we have to decide is what to do with the time that is given to us.
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-2024 The XOOPS Project