Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

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

Members: 0
Guests: 177

more...

Support us!

Headlines

 
  Register To Post  

MUI: How to update bitmap class's bitmap or SourceColors
Quite a regular
Quite a regular


See User information
Hi everybody,

I have a large number of bitmaps (all the same bitmap data) which I want to change the source bitmap of on the fly.
When I change the MUIA_Bitmap_Bitmap at the moment, nothing happens until I iconify and bring back the window - at which point it all looks correct.

How can I force MUI to change the bitmap source data safely and cleanly?

I think I may need to make a subclass but I'm not sure how to do this with a Bitmap class and make it able to use the standard MUI bitmap class but redraw it on demand.

Can anyone help?

Thanks!

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just popping in
Just popping in


See User information
You will have to take a little detour to enforce the necessary relayout of the bitmap object. Take this object definition for example:

grp HGroup,
  
Childbm BitmapObject
    
MUIA_Bitmap_Bitmapinitialbitmap,
    ...
  
End,
End;


To set a new bitmap do this:
if(DoMethod(grpMUIM_Group_InitChange))
{
  
DoMethod(grpOM_REMMEMBERbm);
  
SetAttrs(bmMUIA_Bitmap_Bitmapnewbitmap, ..., TAG_DONE);
  
DoMethod(grpOM_ADDMEMBERbm);
  
DoMethod(grpMUIM_Group_ExitChange);
}


The relayout is enforced by removing and readding the bitmap object.

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Quite a regular
Quite a regular


See User information
Thank you! That works!

I wish that was documented somewhere though! I could find nothing about this anywhere!

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just popping in
Just popping in


See User information
Quote:
I wish that was documented somewhere though! I could find nothing about this anywhere!


I just added a short note the Autodocs of Bitmap.mui.

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Quite a regular
Quite a regular


See User information
Fantastic, thank you! That should help future coders. :)

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Home away from home
Home away from home


See User information
Quote:
When I change the MUIA_Bitmap_Bitmap at the moment, nothing happens until I iconify and bring back the window

That's strange, because that's what eGame is doing at the moment, and it Works For Me (TM).

set(object, MUIA_Bitmap_Bitmap, newBitmap)

For AROS's Zune I did have to kludge it to refresh, but I assumed this was a bug (since it works on MorphOS as well as OS4 when I do it). Here was my kludge (don't do this at home!) :
set(object, MUIA_ShowMe, MUI_FALSE)
set(object, MUIA_ShowMe, MUI_TRUE)

@tboeckel
Any idea why it works for me? And why doesn't MUI act intelligently & refresh the bitmap when it is changed (in some circumstances anyway)?

EDIT: Changed sentence for clarity.


Edited by ChrisH on 2013/3/22 14:19:23
Author of the PortablE programming language.
Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just popping in
Just popping in


See User information
Quote:

ChrisH wrote:
That's strange, because that's what eGame is doing at the moment, and it Works For Me (TM).

set(object, MUIA_Bitmap_Bitmap, newBitmap)


Most probably you didn't use MUIA_Bitmap_SourceColors then (or any other attribute which might cause the bitmap to be remapped). In this case setting a new bitmap will correctly redraw the new one. Otherwise you will also trigger a redraw event, but still with the old bitmap.

Quote:
For AROS's Zune I did have to kludge it to refresh, but I assumed this was a bug since MorphOS as well as OS4 when I do it. Here was my kludge (don't do this at home!) :
set(object, MUIA_ShowMe, MUI_FALSE)
set(object, MUIA_ShowMe, MUI_TRUE)


This is almost the same as removing and readding the bitmap object, but a little bit worse as this will effectively cause two refresh cycles instead of just one.

Quote:
@tboeckel
Any idea why it works for me? And why doesn't MUI act intelligently & refresh the bitmap when it is changed (in some circumstances anyway)?


I cannot really tell why stunzi implemented it this way. I guess it was done this way because usually people use the set() macro instead of SetAttrs() directly. The macro allows to modify one attribute with each call only. The point is that modifying the bitmap might require more than one attribute to be changed (mask, colors, etc). Setting all these attributes with single set() calls instead of one SetAttrs() call would have resulted in a redraw action for each set() call. And even worse it even might cause graphical garbage if the old mask is applied to the new bitmap.

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Home away from home
Home away from home


See User information
Quote:
Most probably you didn't use MUIA_Bitmap_SourceColors then (or any other attribute which might cause the bitmap to be remapped). In this case setting a new bitmap will correctly redraw the new one. Otherwise you will also trigger a redraw event, but still with the old bitmap.

That's correct, I had already manually remapped the bitmap to the screen, so it doesn't need remapping further. Probably not advisable to normal MUI programs (which could in principle change screens at any time), but I think (may be wrong) that I forced which screen my windows appear on.

Author of the PortablE programming language.
Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just can't stay away
Just can't stay away


See User information
Hi,
I'm playing too with MUI Bitmap, contrary to you, I don't have problem to update my Bitmap but my program (and the OS) freezes when I deiconify my program.
Do you do something special to prepare the deiconification of your Bitmap ?
When I remove it, in iconification phase with REMMEMBER, and not readd it during deiconification, it works.

I have tried the InitCHange, ExitChange method, but it freezes, when I do the following in the deiconification

if (DoMethod(redrawGroupe, MUIM_Group_InitChange))
{
DoMethod(redrawGroupe, OM_REMMEMBER, Im_Data_bmp);
DoMethod(redrawGroupe, OM_REMMEMBER, rect2);
DoMethod(redrawGroupe, OM_REMMEMBER, STR_EnCours_Label);
DoMethod(redrawGroupe, OM_REMMEMBER, boutonGroupe);
SetAttrs(Im_Data_bmp, MUIA_Bitmap_Width, 300,MUIA_Bitmap_Height, 225, MUIA_Bitmap_Bitmap, bitmap_vignette, TAG_DONE);
DoMethod(redrawGroupe, OM_ADDMEMBER, Im_Data_bmp);
DoMethod(redrawGroupe, OM_ADDMEMBER, rect2);
DoMethod(redrawGroupe, OM_ADDMEMBER, STR_EnCours_Label);
DoMethod(redrawGroupe, OM_ADDMEMBER, boutonGroupe);
DoMethod(redrawGroupe, MUIM_Group_ExitChange);
}

I tried with or without the SetAttrs => KO
I tried without REMMEMER ADDMEMBER of Im_Data_bmp => no freeze (but no Bitmap)

Thank for your help

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just popping in
Just popping in


See User information
Quote:
I'm playing too with MUI Bitmap, contrary to you, I don't have problem to update my Bitmap but my program (and the OS) freezes when I deiconify my program.


A simple system freeze is not much of a basis to help you. Is there anything on the serial line?

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just can't stay away
Just can't stay away


See User information
Hello Thore,
Thank for your reply.

Yes there are a lot of thing in the Serial line at the moment of this freeze
(I never think to use serial...)

http://zzd10h.amiga-ng.org/Divers/FastView_Deiconify_crashlog.txt

Thank you by advance if you have a clue (even if you don't have...)

Dump of context at 0xDFB077C0
Trap type: DSI exception
Machine State (raw): 0x100000000200F030
Machine State (verbose): [Hyper] [ExtInt on] [User] [FPU on] [IAT on] [DAT on]
Temporary stack trace:
#0: in module rtg.library+0x0005F110 (0x0241C3F0)
#1: in module rtg.library+0x00055B74 (0x02412E54)
#2: in module rtg.library+0x00019808 (0x023D6AE8)
#3: in module rtg.library+0x00067270 (0x02424550)
#4: in module rtg.library+0x00067398 (0x02424678)
#5: in module kernel+0x000495F0 (0x020495F0)
#6: in module layers.library.kmod+0x00000760 (0x021FAF40)
#7: in module rtg.library+0x0006932C (0x0242660C)
#8: in module rtg.library+0x00069CB8 (0x02426F98)
#9: in module graphics.library.kmod+0x00008D3C (0x023990FC)
...
...
...
Crashed process: FastView (0x5D86DC00)
DSI verbose error description: Access not found in hash or BAT (page fault)
Access was a load operation
0: 00000018 5B4F19F0 7C0903A6 5B4F1A10 00000000 0001735C 5B08D4C0 02B30078
8: 0000001C 60B0C82C 00000008 60AF54D0 6FF20150 00000008 0000000C 00000000
16: 00000008 606A5E10 02B30000 00000000 00000000 00000008 0000000C 5B4F1B32
24: 5CD73C40 0000012C 00000006 0000001C 5B4F19F8 00000007 0000012C 6FF20D4E
CR: 33555155 XER: A0000028 CTR: 0241C690 LR: 02412EA4
DSISR: 40000000 DAR: 60B0C82C


Edited by zzd10h on 2013/4/3 23:29:45
Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just popping in
Just popping in


See User information
Quote:
Thank you by advance if you have a clue (even if you don't have...)


Well, there is nothing special in the log except that the crash is finally happening in rtg.library. How do you create the bitmap? Is it possible that it might become invalid when the application is iconified and hence invalid pointers will be accessed upon uniconification?

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just can't stay away
Just can't stay away


See User information
I create the MUI_Bitmap by passing to it a Bitmap struct created by Datatype.
You think that the struct Bitmap bitmap_vignette could be corrupted when I iconify/deiconify, it's ?

In my global variables :
struct BitMap *bitmap_vignette = NULL;

In my GUI build :

Child, Im_Data_bmp = BitmapObject, MUIA_FixWidth, 300, MUIA_FixHeight, 225, End,

and I load the Bitmap into this BitmapObject with.

loadVignette();

Object *dtype = NULL;
...
dtype = NewDTObject(nom_fichier,
PDTA_DestMode, PMODE_V43,
PDTA_Remap, TRUE,
PDTA_DitherQuality, 1,
PDTA_ScaleQuality, 0,
TAG_END);
...
res = GetDTAttrs(dtype,
PDTA_BitMapHeader, (ULONG)&bmh,
TAG_DONE);
...
res = GetDTAttrs(dtype,
PDTA_DestBitMap, &bitmap_vignette,
PDTA_BitMapHeader, (ULONG)&bmhd,
TAG_DONE);
if ((bitmap_vignette != NULL) && (res == 2))
{
SetAttrs(Im_Data_bmp, MUIA_Bitmap_Width, 300,MUIA_Bitmap_Height, 225, MUIA_Bitmap_UseFriend, TRUE, MUIA_Bitmap_Bitmap, bitmap_vignette, TAG_DONE);
}


Thanks

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just popping in
Just popping in


See User information
Quote:
I create the MUI_Bitmap by passing to it a Bitmap struct created by Datatype.


What happens to the DT object after you obtained the bitmap from it? Of course it must stay alive as long as the bitmap is used by your Bitmap object, because DisposeDTObject() will free all stuff belonging to the object, including the bitmap you obtained before. If you implemented things really this way, the you must clone the obtained bitmap before you dispose the DT object and use the cloned bitmap for your Bitmap object.

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just can't stay away
Just can't stay away


See User information
Thank you,
it's true that I dispose the DTobject just after to have load the Bitmap Object.

I will try to copy Bitmap with

p96AllocBitMap
and
CompositeTags

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just popping in
Just popping in


See User information
Quote:
I will try to copy Bitmap with

p96AllocBitMap
and
CompositeTags


A simple AllocBitMap + BltBitMap should suffice.

Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Just can't stay away
Just can't stay away


See User information
Great, it works !

To copy in another Bitmap, I use

p96AllocBitMap and BltBitMapTags for no-alpha pictures

and

p96AllocBitMap and CompositeTags for alpha pictures
(some vertical lines with compositetags and no-alpha picture)

Iconification/deiconification works now (without the need of InitChange/ExitChange)

As usual, thank a lot Thore for your great help and for your availability for MUI (and C) newbies.


Go to top
Re: MUI: How to update bitmap class's bitmap or SourceColors
Home away from home
Home away from home


See User information
I'm doing:

1. Allocate temp bitmap
2. BltBitMapTags() copy stuff from window or buffer into temp bitmap
3. compositetags() copy alpha bitmaps onto background
4. BltBitMapTags() copy result from temp bitmap into window.

I don't know way but if use compositetags() to render into Window bitmap it does not work, the graphics is rendered outside.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project