Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
153 user(s) are online (145 user(s) are browsing Forums)

Members: 0
Guests: 153

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->DoDTMethoddto00, (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 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 = IDataTypes->DoDTMethodA( dto, NullWindow, NullRequester, (Msg)&bpa );
            
resread IDataTypes->DoDTMethoddto00, (Msg*)bpaptr );
            
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;
 }


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->DoDTMethodAdto00, (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