Hello guys,
I have a problem with a project I work on. The project has a list of files which are all images. When the user clicks on one of them the image should be loaded at a bitmap.image I have.
I set the bitmap lika that
Later in the code I set these:
The code to read the selected file:
I left here the remarked codes to see the various tests I did.
Unfortunately, as soon as the IIntuition->RefreshSetGadgetAttrs is executed, the program hangs the whole system and I can't get why this happens. As you can see I tested a lot of codes.
Can you please help me to ovveride this problem? Is it OK to use the bitmap.image for this job? Can I also change it's size to match the size of the outer layout?
Thanks in advance for your kind help.
LAYOUT_AddImage, objects[OID_Bitmap_Pic] = IIntuition->NewObject(NULL, "bitmap.image", BITMAP_SourceFile, "logo.png", BITMAP_Screen, screen, BITMAP_Precision, PRECISION_EXACT, BITMAP_Masking, TRUE, BITMAP_Width, 250, BITMAP_Height, 250, TAG_END), CHILD_NoDispose, TRUE,
Object *dt_Obj; struct dtFrameBox dtf = {0}; struct FrameInfo fri = {0}; struct pdtScale pdt; struct gpLayout gpl; struct BitMap *dt_Bitmap; struct BitMapHeader *bmh = NULL; int srcimagewidth, srcimageheight, srcimagedepth; int DestWidth, DestHeight;
dt_Obj = IDataTypes->NewDTObject((APTR) filename, DTA_SourceType, DTST_FILE, DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, //PDTA_Remap, TRUE, PDTA_Screen, screen, PDTA_FreeSourceBitMap, TRUE, PDTA_ScaleQuality, scalequality, TAG_DONE); if(dt_Obj) { dtf.MethodID = DTM_FRAMEBOX; dtf.dtf_FrameInfo = &fri; dtf.dtf_ContentsInfo = &fri; dtf.dtf_SizeFrameInfo = sizeof(struct FrameInfo); if(IIntuition->IDoMethodA(dt_Obj,(Msg)&dtf) && fri.fri_Dimensions.Depth) { pdt.MethodID = PDTM_SCALE; pdt.ps_NewWidth = width; pdt.ps_NewHeight = height; pdt.ps_Flags = 0; if(!(IIntuition->IDoMethodA(dt_Obj,(Msg)&pdt))) printf("Datatype scaling missed\n"); gpl.MethodID = DTM_PROCLAYOUT; gpl.gpl_GInfo = NULL; gpl.gpl_Initial = 1; if(IIntuition->IDoMethodA(dt_Obj,(Msg)&gpl)) { IDataTypes->GetDTAttrs(dt_Obj, PDTA_DestBitMap, &dt_Bitmap, PDTA_BitMapHeader, (ULONG)&bmh, TAG_DONE); //if(dt_Bitmap) //{ //Determine the source image size srcimagewidth = bmh->bmh_Width; srcimageheight = bmh->bmh_Height; srcimagedepth = bmh->bmh_Depth; printf("Display-Photo: Starting image size imagewidth %d, imageheight %d\n", srcimagewidth,srcimageheight); //dt_Bitmap = IP96->p96AllocBitMap( srcimagewidth, srcimageheight, 32, BMF_DISPLAYABLE, NULL, RGBFB_A8R8G8B8 ); //dt_Bitmap = IGraphics->AllocBitMap( srcimagewidth, srcimageheight, 32, BMF_CLEAR|BMF_DISPLAYABLE, screen->RastPort.BitMap); /* struct RenderInfo renderInfo; lock = IP96->p96LockBitMap(dt_Bitmap, (UBYTE*)&renderInfo, sizeof(renderInfo)); srcBytesPerRow = IP96->p96GetBitMapAttr(dt_Bitmap, P96BMA_BYTESPERROW); IIntuition->IDoMethod(dt_Obj, PDTM_READPIXELARRAY, renderInfo.Memory, PBPAFMT_ARGB, srcBytesPerRow, 0, 0, srcimagewidth, srcimageheight, TAG_END); //Unlock the bitmap IP96->p96UnlockBitMap(dt_Bitmap, lock);*/ if(dt_Bitmap) { //printf("%u\n", objects[OID_Bitmap_Pic]->Width); IIntuition->GetAttrs(objects[OID_Bitmap_Pic], BITMAP_Width, &DestWidth, BITMAP_Height, &DestHeight, TAG_DONE); printf("Display-Photo: Destination gadget image size imagewidth %d, imageheight %d\n", DestWidth,DestHeight); IIntuition->RefreshSetGadgetAttrs((struct Gadget *)objects[OID_Bitmap_Pic], (struct Window *)wins[WIN_COMICA_MAIN], NULL, LAYOUT_ModifyChild, objects[OID_Bitmap_Pic], CHILD_ReplaceObject, dt_Bitmap, TAG_DONE); /*IIntuition->RefreshSetGadgetAttrs((struct Gadget *)objects[OID_LAYOUT_MAIN], (struct Window *)wins[WIN_COMICA_MAIN], NULL, LAYOUT_ModifyChild, objects[OID_Bitmap_Pic], CHILD_ReplaceObject, dt_Bitmap, TAG_END ); */ } //} //else printf("It isn't a bitmap\n"); } else printf("The picture cannot be displayed\n"); } else printf("Cannot use the datatype\n"); IDataTypes->DisposeDTObject(dt_Obj); } else printf("No suitable datatype\n");