]> bicyclesonthemoon.info Git - ott/enhance/blobdiff - bluenh.c
debug build target; updated config tool; install script
[ott/enhance] / bluenh.c
index 79dbd24dfed09a2cf290e8995f234196f45d68a7..f053a499e89fabd2d068eafc1a1d21273a611b63 100644 (file)
--- a/bluenh.c
+++ b/bluenh.c
@@ -1,7 +1,7 @@
 /*
 bluenh.c
 ENHANCE the bluepix!
-13.11.2022
+28.11.2022
 
 Copyright (C) 2015, 2022  Balthasar SzczepaƄski
 
@@ -48,7 +48,7 @@ struct bluenh_data
        ILint64 r_low;
        ILint64 s_low;
        ILint64 t_low;
-       ILint64 max;
+       ILuint max;
 };
 
 int bluenhance (ILuint n, struct PixelInfo *p, void *data);
@@ -63,7 +63,7 @@ int subtool_bluenh (int argc, char **argv, int argi, char **err)
        ILubyte v;
        struct bluenh_data data;
        struct IL_full_info info;
-       FLAG_TYPE flags = CAN_BE_MULTIPLE | CAN_BE_OVER_8BIT;
+       FLAG_TYPE flags = CAN_BE_MULTIPLE | CAN_BE_OVER_8BIT | OK_PALETTE_ONLY;
        int r;
        
        if (argc < argi + 8)
@@ -72,7 +72,7 @@ int subtool_bluenh (int argc, char **argv, int argi, char **err)
                return EINVAL;
        }
        
-       r = create_pictures(1);
+       r = reserve_pictures(1);
        if (r)
        {
                *err = CREATE_FAILED;
@@ -103,7 +103,7 @@ int subtool_bluenh (int argc, char **argv, int argi, char **err)
                data.max = upscale_value(0xFF, info.image_bpc);
                calculate_bluenh_parameters (&data);
                
-               r = action_1picture (
+               r = perform_action_1picture (
                        0,
                        0, 0, 0, 0, 0, 0,
                        &bluenhance,
@@ -194,9 +194,9 @@ void calculate_bluenh_parameters (struct bluenh_data *data)
        data->r_high = (ILint64)(data->f) - (ILint64)(data->e);
        data->s_high = (ILint64)(data->c) - (ILint64)(data->b);
        data->t_high =((ILint64)(data->e))*((ILint64)(data->c))-((ILint64)(data->b))*((ILint64)(data->f));
-       data->r_high = (ILint64)(data->e) - (ILint64)(data->d);
-       data->s_high = (ILint64)(data->b) - (ILint64)(data->a);
-       data->t_high =((ILint64)(data->d))*((ILint64)(data->b))-((ILint64)(data->a))*((ILint64)(data->e));
+       data->r_low = (ILint64)(data->e) - (ILint64)(data->d);
+       data->s_low = (ILint64)(data->b) - (ILint64)(data->a);
+       data->t_low =((ILint64)(data->d))*((ILint64)(data->b))-((ILint64)(data->a))*((ILint64)(data->e));
 }
 
 static inline ILuint bluenh_linear (ILuint x, ILint64 r, ILint64 s, ILint64 t, ILuint max)
@@ -229,175 +229,3 @@ static inline ILuint bluenh_mid (ILuint x, ILuint low, ILuint high_old, ILuint h
                max
        );
 }
-
-/*
-#define INPIX_MUSTARD 1
-#define OUTPIX_MUSTARD 2
-
-#define ARGUMENT_MUSTARD 4
-
-#define ANIMATED_MUSTARD 6
-#define FAIL 900
-#define OK 0
-
-#define CR newdata[4*(i+inX*j)+0]
-#define CG newdata[4*(i+inX*j)+1]
-#define CB newdata[4*(i+inX*j)+2]
-
-#define A ((long)(a))
-#define B ((long)(b))
-#define C ((long)(c))
-#define D ((long)(d))
-#define E ((long)(e))
-#define F ((long)(f))
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <IL/il.h>
-
-void mustard(int mustard);
-ILubyte enhance(ILubyte x, long r, long s, long t);
-ILubyte enhance2(ILubyte x, ILubyte a, ILubyte b, ILubyte c, ILubyte d, ILubyte e, ILubyte f);
-ILubyte enhance3(ILubyte x, ILubyte a, ILubyte b, ILubyte c);
-int main (int argc, const char *argv[]);
-
-ILuint pix;
-ILboolean q=true;
-ILboolean pixOpen=false;
-
-
-ILubyte enhance(ILubyte x, long r, long s, long t)
-{
-       long y=(r*x+t)/s;
-       return (ILubyte)((y>255)?255:((y<0)?0:y));
-}
-
-ILubyte enhance2(ILubyte x, ILubyte a, ILubyte b, ILubyte c, ILubyte d, ILubyte e, ILubyte f)
-{
-       return ((x<=a)?d:((x>=c)?f:((x>b)?(enhance(x,F-E,C-B,E*C-B*F)):((x<b)?(enhance(x,E-D,B-A,D*B-A*E)):e))));
-}
-
-ILubyte enhance3(ILubyte x, ILubyte a, ILubyte b, ILubyte c)
-{
-       return enhance(x,C-A,B-A,(B-C)*A);
-}
-
-int main (int argc, const char *argv[])
-{
-       ILubyte a,b,c,d,e,f,g;
-       ILubyte *h, *s, *l;
-       ILuint inX, inY;
-       ILubyte *newdata;
-       
-       if(argc<9)
-               mustard(ARGUMENT_MUSTARD);
-       if (argc>=10)
-       {
-               if (argv[9][0]=='q' || argv[9][0]=='Q')
-                       q=false;
-       }
-       
-       sscanf(argv[3],"%hhu",&a);
-       sscanf(argv[4],"%hhu",&b);
-       sscanf(argv[5],"%hhu",&c);
-       sscanf(argv[6],"%hhu",&d);
-       sscanf(argv[7],"%hhu",&e);
-       sscanf(argv[8],"%hhu",&f);
-       
-       ilInit();
-       if(!ilEnable(IL_ORIGIN_SET))mustard(FAIL);
-       if(!ilEnable(IL_FILE_OVERWRITE))mustard(FAIL);
-       ilClearColour(255,255,0,0);
-       ilGenImages(1, &pix);
-       pixOpen=true;
-       ilBindImage(pix);
-       if(!ilLoadImage(argv[1]))mustard(INPIX_MUSTARD);
-       if(!ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE))mustard(INPIX_MUSTARD);
-       
-       inX=ilGetInteger(IL_IMAGE_WIDTH);
-       inY=ilGetInteger(IL_IMAGE_HEIGHT);
-       if(ilGetInteger(IL_NUM_IMAGES)>1)
-               mustard(ANIMATED_MUSTARD);
-       
-       newdata=ilGetData();
-       for(unsigned long i=0;i<inX;++i)
-       {
-               for(unsigned long j=0;j<inY;++j)
-               {
-                       if(CR==CG&&CG==CB)
-                               continue;
-                       //it'll stilll work correctly if two are equal.
-                       if(CR>CG)
-                       {
-                               if(CG>CB)
-                               {
-                                       h=&(CR);
-                                       s=&(CG);
-                                       l=&(CB);
-                               }
-                               else if(CB>CR)
-                               {
-                                       h=&(CB);
-                                       s=&(CR);
-                                       l=&(CG);
-                               }
-                               else
-                               {
-                                       h=&(CR);
-                                       s=&(CB);
-                                       l=&(CG);
-                               }
-                       }
-                       else
-                       {
-                               if(CR>CB)
-                               {
-                                       h=&(CG);
-                                       s=&(CR);
-                                       l=&(CB);
-                               }
-                               else if(CB>CG)
-                               {
-                                       h=&(CB);
-                                       s=&(CG);
-                                       l=&(CR);
-                               }
-                               else
-                               {
-                                       h=&(CG);
-                                       s=&(CB);
-                                       l=&(CR);
-                               }
-                       }
-                       g=*h;
-                       *h=enhance2(*h,a,b,c,d,e,f);
-                       *s=enhance3(*s,*l,g,*h);
-               }
-       }
-       if(!ilSave(IL_PNG,argv[2]))mustard(OUTPIX_MUSTARD);
-       // no mustard
-       mustard(0);
-}
-
-void mustard(int mustard)
-{
-       switch(mustard)
-       {
-       case 0:
-               if(q) printf("ENHANCED!\n");break;
-       case ARGUMENT_MUSTARD:
-               if(q) printf("bluenhanced inPix outPix a b c d e f [q]\n");break;
-       case INPIX_MUSTARD:
-               if(q) printf("inPIX mustard.\n");break;
-       case OUTPIX_MUSTARD:
-               if(q) printf("outPIX mustard.\n");break;
-       case ANIMATED_MUSTARD:
-               if(q) printf("Animation is mustard.\n");break;
-       default:
-               if (q) printf("Ch*rpin* mustard mustaard!\n");
-       }
-       if(pixOpen)
-               ilDeleteImages(1, &pix);
-       exit(mustard);
-}
-*/