website logo
Auteur
avatar
thellier

Forum » » Création-Développement » » Les datatypes me rendent dingue


Posté : 21-10-2014 11:36 icone du post

AAAARGHHH j'arrive toujours pas à sauver une bitmap avec les datatypes


DoDTMethod donne result à 1 et le fichier iff est vide (taille 0)

J'avais aussi essayé un


result=DoDTMethod(dto,NULL,NULL,DTM_WRITE,NULL,fp,DTWM_IFF,NULL);


juste après le chargement par datatype d'un jpg et làa ça marche


Voilà le code
Avec quelques spécificités (qui marchent ailleurs dans ma microbe3d.library):
MyDoMethodA car j'utilise pas libamiga
BmReadPixelArray : séparée pour éviter l'erreur gcc "missing registers"
MMfree/MMalloc: sont mes fonctions d'allocation mémoires tracées


/*=================================================== ===============================*/
inline ULONG MyDoMethodA(Object * obj,Msg msg)
{
ULONG result=0;
Class * cl;

if(obj==NULL)
return(result);
cl = OCLASS(obj);

if(cl==NULL)
return(result);

result =CallHookPkt(&cl->cl_Dispatcher,obj,msg);
return(result);
}
/*= =============================================================================== ==*/
void BmReadPixelArray(UBYTE *buf,void *rast,ULONG width,ULONG height)
{
ReadPixelArray(buf,0,0,(width*24/8),rast,0,0,width,height,RECTF MT_RGB);
}
/*============================================================ ======================*/
void SaveBitmap(Scene3D *S,UBYTE *filename)
{
Object *dto=NULL;
UBYTE *buf=NULL;
BPTR fp=NULL;
struct BitMap *bm;
struct pdtBlitPixelArray bpa;
APTR bitMapHandle;
ULONG width,height;
ULONG result;

bm=S->bufferrastport.BitMap;
Libprintf("SaveBitmap bm %ld \n",bm);

bitMapHandle = LockBitMapTags(bm, LBMI_WIDTH, (ULONG)&width, LBMI_HEIGHT, (ULONG)&height,TAG_END);
if(!bitMapHandle) goto panic;
UnLockBitMap(bitMapHandle);

dto = NewDTObject(NULL, DTA_SourceType,DTST_RAM, DTA_GroupID,GID_PICTURE, TAG_DONE);
if(!dto) goto panic;

buf = MMmalloc(24/8*width*height,"buf");
if(!buf) goto panic;

BmReadPixelArray(buf,&S->bufferrastport,width,height);

result=SetDTAttrs (dto, NULL, NULL,
DTA_ObjName, (ULONG)"Microbe3D grab",
DTA_NominalHoriz, width,
DTA_NominalVert, height,
PDTA_SourceMode, PMODE_V43,
TAG_DONE);
if(result) goto panic;

bpa.MethodID = PDTM_WRITEPIXELARRAY;
bpa.pbpa_PixelData = buf;
bpa.pbpa_PixelFormat = PBPAFMT_RGB;
bpa.pbpa_PixelArrayMod = width*24/8;
bpa.pbpa_Left = 0;
bpa.pbpa_Top = 0;
bpa.pbpa_Height = height;
bpa.pbpa_Width = width;
result=MyDoMethodA(dto,(Msg)&bpa);
if(result) goto panic;

result=DoDTMethod(dto,NULL,NULL,DTM_CLEARSELECTED,NULL);
if(re sult) goto panic;

fp=Open(filename,MODE_NEWFILE);
if(!fp) goto panic;
result=DoDTMethod(dto,NULL,NULL,DTM_WRITE,NULL,fp,DTWM_IFF,NULL);
Libprintf(" result:%ld for buf %ld %ldX%ld (bm %ld dto %ld fp %ld)\n",result,buf,width,height,bm,dto,fp);
panic:
if(fp) Close(fp);
if(dto) DisposeDTObject(dto);
if(buf) MMfree(buf);
}
/*==================================================================== ==============*/


Cet article provient de Le site des utilisateurs francophones actuels et futurs d'AmigaOS 4.x
https://amiga-ng.org/viewtopic.php?topic=1951&forum=14