Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
119 user(s) are online (70 user(s) are browsing Forums)

Members: 0
Guests: 119

more...

Headlines

 
  Register To Post  

Fading effect on 24bit ARGB screens
Just popping in
Just popping in


See User information
Hi Guys, I'm looking for a fast and simple fading effect for OS4 and 24bit ARGB screens.
My primary goal is a "fade to black" effect but as second option a "fade from black" is welcome too. I'm looking for some C code already done to adapt in a fast way. Tnx!

Go to top
Re: Fading effect on 24bit ARGB screens
Just can't stay away
Just can't stay away


See User information
@flash

You could use CompositeTags. You need 2 displayable bitmaps. One for source (1*1 pixel black color, or rather: black + alpha) and one for destination. Then you can draw 2 triangles over destination using source as a texture. Finally you can blit the destination bitmap to a window.

Some code: https://github.com/AmigaPorts/SDL-2.0/ ... render_compositing.c#L407

Go to top
Re: Fading effect on 24bit ARGB screens
Just popping in
Just popping in


See User information
Thank you I can give it a look.
Really I was looking for something much simpler, without use of SDL. Is there any other spot?

Memento audere semper!
Go to top
Re: Fading effect on 24bit ARGB screens
Just can't stay away
Just can't stay away


See User information
@flash

CompositeTags() is not related to SDL, it's a Graphics Library function. Capehill is merely pointing to how the function is used in his SDL port. Have a look at the Graphics Library autodocs.

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: Fading effect on 24bit ARGB screens
Just popping in
Just popping in


See User information
For now I have resolved with this Fade (to black) C function, it's perfect on 8bit screens, and good for 24bit screens in low/med resolutions. In hires it's a bit slow. Maybe in future I can look for compositing use to get a butter effect even on 24bit/hires screens.
Anyway some hardware acceleration can be inside ReadPixelArray and WritePixelArray OS4 API Calls, but fading effect is all cpu brute force, writing in system memory.

Here is complete C function, it works ok when I use "Win->Width * 4" inside Read/WritePixelArray api calls, but fails if I use Win->RPort->Bitmap->BytesPerRow value.

extern uint8 *ARGBMEM;

int16 Fade (struct Window *Win, uint32 *PaletteSrc, uint32 MaxStep, uint32 MyTimeDelay, int16 ToBlack)
{
// DisplayInfoHandle DHandle;
// struct DimensionInfo DimInfo;
static uint32 __attribute__ ((aligned (16))) PaletteTmp [3L * 252L + 2L];
// uint8 *ARGB = NULL;
uint8 R, G, B;
int16 Success = FALSE;
uint32 Var, Step, Rows, Cols, Modulo;
uint32 DstWinWidth, DstWinHeight, Depth, Color, Range, ModeID;
/*
ModeID = GetVPModeID (ViewPortAddress (Win));
DHandle = FindDisplayInfo (ModeID);

if (!((DHandle) && GetDisplayInfoData (DHandle, (uint8 *) &DimInfo, sizeof (struct DimensionInfo), DTAG_DIMS, ModeID))) goto ExitFade;
*/
DstWinWidth = ((Win->Flags & WFLG_GIMMEZEROZERO) ? Win->GZZWidth : Win->Width);
DstWinHeight = ((Win->Flags & WFLG_GIMMEZEROZERO) ? Win->GZZHeight : Win->Height);
Depth = GetBitMapAttr (Win->RPort->BitMap, BMA_DEPTH);

if (Depth == MIN_DEPTH) // 8 bit screens
{
if (ToBlack)
{
Range = (1L << Depth) - 4L;
PaletteTmp [0L] = (Range << 16L) + 4L;
GetRGB32 (((struct ViewPort *) ViewPortAddress (Win))->ColorMap, 4L, Range, &PaletteTmp [1L]);
PaletteTmp [3L * Range + 1L] = NULL;
PaletteSrc += (3 * RESERVED_PENS); /* exclude reserved pens for GUI */

for (Step = 0L; Step <= MaxStep; Step++)
{
for (Var = 1; Var <= 3L * Range; Var+=3) /* unroll loop 3 times */
{
if (PaletteTmp [Var + 0])
{
Color = (uint32) (((PaletteSrc [Var + 0] >> 24L) * (MaxStep - Step)) / MaxStep);
PaletteTmp [Var + 0] = (Color << 24L);
}

if (PaletteTmp [Var + 1])
{
Color = (uint32) (((PaletteSrc [Var + 1] >> 24L) * (MaxStep - Step)) / MaxStep);
PaletteTmp [Var + 1] = (Color << 24L);
}

if (PaletteTmp [Var + 2])
{
Color = (uint32) (((PaletteSrc [Var + 2] >> 24L) * (MaxStep - Step)) / MaxStep);
PaletteTmp [Var + 2] = (Color << 24L);
}
}

WaitTOF ();
LoadRGB32 (ViewPortAddress (Win), &PaletteTmp);
Delay (MyTimeDelay);
}
}

else
{
for (Var = 0; Var < ((DstWinWidth * DstWinHeight) / 4); Var++)
WritePixelColor (Win->RPort, rand() % (DstWinWidth - 1), rand() % (DstWinHeight - 1), 0xff000000);
}

Success = TRUE;
goto ExitFade;
}

else if (Depth == MAX_DEPTH) // 24bit screens
{
if (ToBlack)
{
Modulo = DstWinWidth;

ReadPixelArray (Win->RPort, 0, 0, ARGBMEM, Win->LeftEdge, Win->TopEdge,
Modulo * 4, PIXF_A8R8G8B8, DstWinWidth, DstWinHeight);

for (Step = 0L; Step <= MaxStep; Step++)
{
for (Cols = Win->TopEdge; Cols < (DstWinHeight * 4); Cols += 4)
{
for (Rows = Win->LeftEdge; Rows < (DstWinWidth * 4); Rows += 8) // unroll loop twice
{
if ((R = *(ARGBMEM + (Cols * Modulo + (Rows + 1)))))
*(ARGBMEM + (Cols * Modulo + (Rows + 1))) = (uint8) ((R * (MaxStep - Step)) / MaxStep);

if ((G = *(ARGBMEM + (Cols * Modulo + (Rows + 2)))))
*(ARGBMEM + (Cols * Modulo + (Rows + 2))) = (uint8) ((G * (MaxStep - Step)) / MaxStep);

if ((B = *(ARGBMEM + (Cols * Modulo + (Rows + 3)))))
*(ARGBMEM + (Cols * Modulo + (Rows + 3))) = (uint8) ((B * (MaxStep - Step)) / MaxStep);

if ((R = *(ARGBMEM + (Cols * Modulo + (Rows + 5)))))
*(ARGBMEM + (Cols * Modulo + (Rows + 5))) = (uint8) ((R * (MaxStep - Step)) / MaxStep);

if ((G = *(ARGBMEM + (Cols * Modulo + (Rows + 6)))))
*(ARGBMEM + (Cols * Modulo + (Rows + 6))) = (uint8) ((G * (MaxStep - Step)) / MaxStep);

if ((B = *(ARGBMEM + (Cols * Modulo + (Rows + 7)))))
*(ARGBMEM + (Cols * Modulo + (Rows + 7))) = (uint8) ((B * (MaxStep - Step)) / MaxStep);
}
}

WaitTOF ();
WritePixelArray (ARGBMEM, 0, 0, Modulo * 4, PIXF_A8R8G8B8,
Win->RPort, Win->LeftEdge, Win->TopEdge, DstWinWidth, DstWinHeight);
Delay (MyTimeDelay);
}
}

else
{
for (Cols = Win->TopEdge; Cols < DstWinHeight; Cols += 2)
{
for (Rows = Win->LeftEdge; Rows < DstWinWidth; Rows += 4) // unroll loop twice
{
WritePixelColor (Win->RPort, Rows, Cols, 0xff000000);
WritePixelColor (Win->RPort, Rows + 2, Cols, 0xff000000);
}

Delay (MyTimeDelay / 2);
}
}

Success = TRUE;
}

ExitFade:
return (Success);
}

Memento audere semper!
Go to top
Re: Fading effect on 24bit ARGB screens
Just popping in
Just popping in


See User information
Hi,

Reaction window can do fading effect.

https://wiki.amigaos.net/wiki/Programm ... OS_4:_Transparent_Windows

You could show a black window with screen size settings and switch to its own screen after the fade effect, and do the reverse on exit.

Regards,

Go to top
Re: Fading effect on 24bit ARGB screens
Just can't stay away
Just can't stay away


See User information
@flash

Quote:

Here is complete C function, it works ok when I use "Win->Width * 4" inside Read/WritePixelArray api calls, but fails if I use Win->RPort->Bitmap->BytesPerRow value.


The BytesPerRow argument is for your own buffer and not for the rastport.

Go to top
Re: Fading effect on 24bit ARGB screens
Just popping in
Just popping in


See User information
@Petrol

Good spot, I'll have to made main window a reaction window.
Thanks!

Go to top
Re: Fading effect on 24bit ARGB screens
Just popping in
Just popping in


See User information
@salass00

I use to look as much as possible your code on the net
Thank you for your answer.

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-2023 The XOOPS Project