Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
81 user(s) are online (62 user(s) are browsing Forums)

Members: 1
Guests: 80

Nuder_Try, more...

Headlines






Load picture with datatypes
Just popping in
Joined:
2018/3/1 21:08
From italy
Posts: 41
Hi Amigans,
I need a fast help to resolve a issue about 8 bit (256 colors) images.
The following snippet code works ok with 24 bit images but fails to load 8 bit ones. I don't need to load 15/16 bit pictures.
The image is displayed but with less colors.
I grabbed code from Thomas examples

int32
LoadPic (struct ILBMInfo *ilbm, uint8 *filename)
{
int32 Error;
uint32 Width, Height, Depth;
Object *dto;

Error = TRUE;
Width = ilbm->Bmhd.w;
Height = ilbm->Bmhd.h;
Depth = ilbm->Bmhd.nPlanes;

if ((Depth == MIN_DEPTH) || (Depth == MAX_DEPTH))
{
if((dto = NewDTObject(filename,
DTA_SourceType, DTST_FILE,
DTA_GroupID, GID_PICTURE,
PDTA_Screen,ilbm->scr,
PDTA_UseFriendBitMap,TRUE,
PDTA_DestMode, PMODE_V43,
TAG_END)))
{
SetDTAttrs(dto,NULL,NULL,
GA_Left, 0,
GA_Top, 0,
GA_Width, Width,
GA_Height, Height,
ICA_TARGET, ICTARGET_IDCMP,
TAG_END);

AddDTObject(ilbm->win,NULL,dto,-1);
RefreshDTObjects(dto,ilbm->win,NULL,NULL);
RemoveDTObject(ilbm->win,dto);
DisposeDTObject(dto);
Error = FALSE;
}
}

return Error;
}

   Report Go to top

Re: Load picture with datatypes
Just popping in
Joined:
2018/3/1 21:08
From italy
Posts: 41
I did not set the following TAG to FALSE

"PDTA_Remap,FALSE"

I remember it should be default.

Anyway I have anoter issue to resolve.. How I can add chunks inside iff file I have to write?
In "datatypeclass.h" include file I read, among others, following defines

#define DTA_ObjAuthor (DTA_Dummy+110)
#define DTA_ObjCopyright (DTA_Dummy+112)
#define DTA_ObjVersion (DTA_Dummy+113)
#define DTA_UserData (DTA_Dummy+115)

I'd like use them to write and read some values inside iff file (picture in my case) without use an external file.

Thanks!


   Report Go to top

Re: Load picture with datatypes
Home away from home
Joined:
2006/12/4 23:15
Posts: 2296
Your first snippet of code has

if ((Depth == MIN_DEPTH) || (Depth == MAX_DEPTH))

should that not be

if ((Depth >= MIN_DEPTH) || (Depth <= MAX_DEPTH))

Quote:

"PDTA_Remap,FALSE"

I remember it should be default.


So did you set this to TRUE to make it work? Or the other way round?

As to saving with custom chunks, there is no way to do this with datatypes. You could possibly save to a temp file then append your custom chnks to that file (updating the FORM size to match). That way you'd only jave to worry about saving your custom data and you could let picture.datatype handle the image saving.

_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Load picture with datatypes
Just popping in
Joined:
2018/3/1 21:08
From italy
Posts: 41
I manage only 8 bit and 24 bit screens so other cases have to be excluded.

I can confirm setting PDTA_Remap to FALSE in NewDTObject function call resolved my issue, now pictures are correctly displayed.

About custom chunks sadly you confirmed my fears.
..but what are these defines in "datatypeclass.h" include file?

#define DTA_ObjAuthor (DTA_Dummy+110)
#define DTA_ObjCopyright (DTA_Dummy+112)
#define DTA_ObjVersion (DTA_Dummy+113)
#define DTA_UserData (DTA_Dummy+115)

Anyway IFF could be better supported because it's still a good standard to write data and represents one of the amiga good peculiarities.

I hope there will be written some high level calls to use datatypes in a more easy way in next OS releases.
i.e. SaveWinBitmap or LoadBitmapWin functions call with some useful arguments to pass in

_________________
Memento audere semper!
   Report Go to top

Re: Load picture with datatypes
Quite a regular
Joined:
2006/12/24 12:23
From Germany
Posts: 522
@flash

Hi Dino,

the only information I could find is in the file "Class.c" in the directory "Examples/AHI/Low-level/PTdatatype" of the AmigaOS4 SDK.

DTA_ObjName and DTA_UserData is used there. The question is, if the data is written into file, when you save it with the ILBM datatype.

_________________
X-5000 PPC 5020/2 GHZ, Fractal Define XL R2-Tower, OS 4.1 final pre, 4 GB, Radeon HD 7770, ESI Juli@ XTe
SAM 460ex/1,15 GHZ, OS 4.1 final, 2 GB, Radeon HD 6450
Amiga 4000D/040 25 Mhz, OS 3.9 BB2, 272 MB, X-Surf, 250 MB ZIP
   Report Go to top

Re: Load picture with datatypes
Home away from home
Joined:
2006/12/4 23:15
Posts: 2296
@flash

Depending on the datatypes class in question those attributes may be filled in when the object is opened.

Quote:

I hope there will be written some high level calls to use datatypes in a more easy way in next OS releases.
i.e. SaveWinBitmap or LoadBitmapWin functions call with some useful arguments to pass in


Datatypes is already fairly high level in that is doesn't care what image type you load as long as there is datatype for it.

Depending what you are doing with you images bitmap.image might be a solution for higher level image loading.

There is also IIntuition->ObtainBitMapSourceA and ObtainBitMapInstanceA

_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: Load picture with datatypes
Just popping in
Joined:
2018/3/1 21:08
From italy
Posts: 41
@broadblues

I have modified code to try to implement custom chunks as suggested by Edgar, iff file is saved but opening it with an editor does not show presence of desired informations (custom chunks)

Here is my code, please look at followinf line

SetDTAttrs (o,NULL,NULL,DTA_Data,"***dino***",DTA_ObjAuthor,"***pippo***",DTA_ObjCopyright,"***pluto***",TAG_END);

it should do the trick and I added some different tags just to test, but nothing hoped happens.

Maybe it's a not fully finished impementation of iff datatype library.

/*----------------------------------------------------------------------------*/
/* Save the inner contents of a GZZ window as IFF picture using datatypes */
/*----------------------------------------------------------------------------*/
int32 savewindow (char *name,struct Window *win)
{
struct BitMap *bm;
Object *o;
struct BitMapHeader *bmhd;
UBYTE *cmap;
ULONG *cregs;
long i;
long w,h,d;
long ncols;
BPTR fhand;
struct ViewPort *vp;
int32 Error;

Error = TRUE;

if (bm = gzzarea (win))
{
w = win->GZZWidth;
h = win->GZZHeight;
d = GetBitMapAttr (bm,BMA_DEPTH);

ncols = (d > 8 ? 0 : 1 << d);

vp = ViewPortAddress (win);

if (o = NewDTObject (NULL,
DTA_SourceType,DTST_RAM,
DTA_GroupID,GID_PICTURE,
PDTA_BitMap,bm,
PDTA_ModeID,GetVPModeID(vp),
(ncols ? PDTA_NumColors : PDTA_DestMode),(ncols ? ncols : PMODE_V43),
TAG_END))
{

/* **** */ SetDTAttrs (o,NULL,NULL,DTA_Data,"***dino***",DTA_ObjAuthor,"***pippo***",DTA_ObjCopyright,"***pluto***",TAG_END);
//SetDTAttrs (o,NULL,NULL,DTA_ObjCopyright,©RIGHT_CHUNK,DTA_ObjAuthor,&USERNAME_CHUNK,TAG_END);

GetDTAttrs (o,PDTA_BitMapHeader,&bmhd,TAG_END);

bmhd->bmh_Width = w;
bmhd->bmh_Height = h;
bmhd->bmh_Depth = d;
bmhd->bmh_XAspect = 22;
bmhd->bmh_YAspect = 22;
bmhd->bmh_PageWidth = (w <= 320 ? 320 : w <= 640 ? 640 : w <= 1024 ? 1024 : w <= 1280 ? 1280 : 1600);
bmhd->bmh_PageHeight = bmhd->bmh_PageWidth * 3 / 4;

if (ncols)
{
GetDTAttrs (o,PDTA_ColorRegisters,&cmap,PDTA_CRegs,&cregs,TAG_END);
GetRGB32 (vp->ColorMap,0,ncols,cregs);
for (i = 3*ncols; i; i--)
*cmap++ = (*cregs++) >> 24;
}

if (fhand = Open (name,MODE_NEWFILE))
{
i = DoDTMethod (o,NULL,NULL,DTM_WRITE,NULL,fhand,DTWM_IFF,NULL);
Close (fhand);
if (i)
Error = FALSE;
else
Delete (name);
}

DisposeDTObject (o);
}
else
FreeBitMap (bm);
}

return Error;
}

   Report Go to top





[Advanced Search]



Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project