Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
123 user(s) are online (109 user(s) are browsing Forums)

Members: 1
Guests: 122

Yodaphone, more...

Support us!

Headlines

 
  Register To Post  

ProcessPixelArray() rewrite
Home away from home
Home away from home


See User information
When porting some stuff from morphos, found that they very offten use ProcessPixelArray(), which is:
Quote:

VOID ProcessPixelArray(struct RastPort *, ULONG, ULONG, ULONG, ULONG, ULONG, LONG, struct TagItem *);


Few defines for:

Quote:

/*
* Operations for ProcessPixelArray() (v50)
*
*/

#define POP_BRIGHTEN 0
#define POP_DARKEN 1
#define POP_SETALPHA 2
#define POP_TINT 3
#define POP_BLUR 4
#define POP_COLOR2GREY 5
#define POP_NEGATIVE 6
#define POP_NEGFADE 7
#define POP_TINTFADE 8
#define POP_GRADIENT 9
#define POP_SHIFTRGB 10


Basically it is function which calculates the gradient shades, but probably in a different way than OS4's DrawGradient() function. Basic parameters are the same more or less on both systems, but probably with different calculation, and so final result (the visible one) can be pretty different.

I only found reimpleminttion of it on AROS (dunno if it finished ?):
https://trac.aros.org/trac/browser/ARO ... /cgfx/processpixelarray.c

That how it uses for example in VPDF:

static void rendermarker(struct Data *datastruct RastPort *rpstruct markernode *mnint x0int y0)
{
    
int x1 mn->ux1y1 mn->uy1;
    
int x2 mn->ux2y2 mn->uy2;

    
SetRPAttrs(rpRPTAG_PenModeFALSERPTAG_FgColor0xffff0000TAG_DONE);

    
RectFill(rpx0 x1 2y0 y2 2x0 x2 2y0 y2 1);
    
RectFill(rpx0 x1 2y0 y1 1x0 x2 2y0 y1 2);
    
RectFill(rpx0 x1 2y0 y2x0 x1 1y0 y1);
    
RectFill(rpx0 x2 1y0 y2x0 x2 2y0 y1);

    
#ifndef __amigaos4__
    
ProcessPixelArray(rpx0 x1 1y0 y2 1x2 x1y1 y2POP_DARKEN10NULL);
    
#endif
}


Thats how it uses for example in Odyssey:

DEFMMETHOD(Draw)
{
    
DOSUPER;

    if (
msg->flags MADF_DRAWOBJECT)
    {
        
struct RastPort *rp _rp(obj);

        
ULONG mleft         _mleft(obj);
        
ULONG mtop          _mtop(obj);
        
ULONG mwidth        _mwidth(obj);
        
ULONG mheight       _mheight(obj);

        
ULONG vertoffs   mleft + (mwidth 2);
#ifndef __amigaos4__
        
ProcessPixelArrayrpvertoffs,     mtop 11mheight 2POP_BRIGHTEN70NULL);
        
ProcessPixelArrayrpvertoffs 1mtop 11mheight 2POP_DARKEN,   70NULL);
#endif

    
}

    return 
0;
}


If anyone can bring just ready to use function that will help, thanks !


Edited by kas1e on 2017/1/14 8:47:38
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: ProcessPixelArray() rewrite
Home away from home
Home away from home


See User information
@all
Combined from AROS sources something (Mazze, you are author seems so ?), which probably should work. Maybe will be in interst of someone to copy+paste someday :) For me only POP_DARKEN and POP_BRIGHTEN need it, and they implemented on AROS:

/* 
        NOTE: TAKEN FROM AROS.

        FUNCTION
            Applies one of a variety of transformations to a rectangular portion
            of a RastPort.
    
        INPUTS
            rp - the RastPort to process.
            destX, destY - top-lefthand corner of portion of RastPort to process.
            sizeX, sizeY - size of the affected area.
            operation - one of the following transformation types:
                POP_TINT - tint the rectangle with an ARGB32 color ('value' input).
                POP_BLUR - blur the rectangle.
                POP_BRIGHTEN - brighten the rectangle. The amount of brightening
                    to be done is defined by the 'value' input, which must be in
                    the range 0 to 255.
                POP_DARKEN - darken the rectangle. The amount of darkening to be
                    done is defined by the 'value' input, which must be in the
                    range 0 to 255.
                POP_SETALPHA - set the alpha channel value for all pixels in the
                    rectangle to that specified in the 'value' input. The valid
                    range is 0 to 255.
                POP_GRADIENT - apply a gradient to the rectangle. Gradient
                    parameters are supplied through the taglist.
            value - see description of 'operation' input.
            taglist - currently describes gradient parameters, as follows:
                PPAOPTAG_GRADIENTTYPE - GRADTYPE_HORIZONTAL or GRADTYPE_VERTICAL.
                PPAOPTAG_GRADCOLOR1 - The starting color of the gradient (ARGB32).
                PPAOPTAG_GRADCOLOR2 - The ending color of the gradient (ARGB32).
                PPAOPTAG_GRADFULLSCALE
                PPAOPTAG_GRADOFFSET
    
        RESULT
            count - the number of pixels processed.
*/

#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/cybergraphics.h>
#include <stdio.h>

#define POP_BRIGHTEN 0
#define POP_DARKEN 1
#define POP_SETALPHA 2
#define POP_TINT 3
#define POP_BLUR 4
#define POP_COLOR2GREY 5
#define POP_NEGATIVE 6
#define POP_NEGFADE 7
#define POP_TINTFADE 8
#define POP_GRADIENT 9
#define POP_SHIFTRGB 10


extern void ProcessPixelArrayBrightnessFunc(struct RastPort *, struct Rectangle *, LONG);
extern void ProcessPixelArray(struct RastPort *, ULONGULONGULONGULONGULONGLONGstruct TagItem *);

void ProcessPixelArrayBrightnessFunc(struct RastPort *opRaststruct Rectangle *opRectLONG value)
{
    
//kprintf("[Cgfx] %s(%d)\n", __PRETTY_FUNCTION__,value);

    
LONG xy;
    
ULONG color;
    
LONG alpharedgreenblue;

    if (
GetBitMapAttr(opRast->BitMapBMA_DEPTH) < 15)
    {
        
//kprintf("[Cgfx] %s not possible for bitmap depth < 15\n", __PRETTY_FUNCTION__);
        
return;
    }

    for(
opRect->MinX<= opRect->MaxXx++)
    {
        for (
opRect->MinY<= opRect->MaxYy++)
        {
            
color ReadRGBPixel(opRastxy);

            
alpha = (color 0xff);
            
red   = (color 0xff00) >> 8;
            
green = (color 0xff0000) >> 16;
            
blue  = (color 0xff000000) >> 24;

            
//kprintf("[Cgfx] %s x %d y %d old: alpha %d red %d green %d blue %d", __PRETTY_FUNCTION__, x, y, alpha, red, green, blue);

            
red += value;
            
green += value;
            
blue += value;

            if (
red 255)
                
red 255;
            else if (
red 0)
                
red 0;
            if (
green 255)
                
green 255;
            else if (
green 0)
                
green 0;
            if (
blue 255)
                
blue 255;
            else if (
blue 0)
                
blue 0;

            
//kprintf(" new: alpha %d red %d green %d blue %d\n", alpha, red, green, blue);

            
color alpha | (red << 8) | (green << 16) | (blue << 24);

            
WriteRGBPixel(opRastxycolor);
        }
    }
}


void ProcessPixelArray(struct RastPort *rpULONG destXULONG destYULONG sizeXULONG sizeYULONG operationLONG valuestruct TagItem *taglist)
{
    
struct Rectangle    opRect;
   
    
opRect.MinX destX;
    
opRect.MinY destY;
    
opRect.MaxX opRect.MinX sizeX 1;
    
opRect.MaxY opRect.MinY sizeY 1;

    switch (
operation)
    {
    case 
POP_BRIGHTEN:
        
ProcessPixelArrayBrightnessFunc(rp, &opRectvalue);
        break;
    case 
POP_DARKEN:
        
ProcessPixelArrayBrightnessFunc(rp, &opRect, -value);
        break;
    case 
POP_SETALPHA:
        break;
    case 
POP_TINT:
        break;
    case 
POP_BLUR:
        break;
    case 
POP_COLOR2GREY:
        break;
    case 
POP_NEGATIVE:
        break;
    case 
POP_NEGFADE:
        break;
    case 
POP_TINTFADE:
        break;
    case 
POP_GRADIENT:
        break;
    case 
POP_SHIFTRGB:
        break;
    default:
        
//kprintf("[Cgfx] %s: Unhandled operation %d\n", __PRETTY_FUNCTION__, operation);
        
break;
    }

}


Edited by kas1e on 2017/1/13 20:27:24
Edited by kas1e on 2017/1/14 8:46:58
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: ProcessPixelArray() rewrite
Not too shy to talk
Not too shy to talk


See User information
@kas1e

This Color values is swapped.. so if you want to use it under AOS4 you need a AARRGGBB format not BBGGRRAA.

Edit: Just commenting your source code for Brighten/Darken.

“The best thing about a boolean is even if you are wrong, you are only off by a bit.”
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