This file is allows you to create UniView plugins supporting Image
operations. If you want to use it, you must agree following text
and you can start programming :-)
Copyright (C)1998-2002 by Andrej Krutak
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose, without
fee, and without written agreement is hereby granted,
provided that the above copyright notice appear in all
copies and that both copyright notice and this permission
notice appear in supporting documentation. This software
is provided "as is" without express or implied warranty.
Changes:
-------------------
1.8
-------------------
+ Updated "UVImage_quantize" and "UVImage_quantize_xbpp" to mirror changes in program
+ Added '...' to all functions' definitions to avoid problems with different versions of UniView - no functions' parameters will be changed, they may be just inserted to end of functions' parameter list
+ Added new functions (also added to program ;-)
* Removed C compatibility issues
-------------------
1.73
-------------------
* Initial version
*/
#define CIMAGEVER 1800
/*
For setting compatibility... Number here is maked as following MMmmm, where
MM is major version (for UniView 1.8 is it 1, here written as 1 :) and mmm is
minor version (UniView 1.8 - 800, UniView 1.886 would be 886 and 1.83: 830).
Just put it together and... UniView 1.8 is 1800
PLEASE NOTE: If you define here e.g. 1.8 and use functions allowed just for this
and newer versions, plugin wouldn't be usable on previous versions (this means
e.g. 1.73).
*/
#include <windows.h>
#define IMAGE_SIZE_RESAMPLE 0
#define IMAGE_SIZE_CROP 1
//Resize filters
#define IMAGE_SIZE_FILTER_DEFAULT 0
//Status of CImage
#define IMAGE_OK 0
#define IMAGE_BAD 1
//CImage load errors
#define OPEN_SUCESS 0
#define UNSUP_FORMAT 1
#define CORRUP_IMAGE 2
#define OUT_OF_MEMORY 3
#define UNKNOWN_ERROR 4
#define BAD_HEADER 5
#define FILE_ERROR 6
#define BAD_COLORTABLE 7
#define BAD_VERSION 8
#define INTERNAL_ERROR 9
#define WARNING_CORRUPTED -1
typedef void * CImage;
#ifdef __cplusplus
extern "C" {
#endif
__declspec (dllexport) CImage* UVImage_create(int xs, int ys, int bpp, ...);
__declspec (dllexport) int UVImage_recreate(CImage *img, int xs, int ys, int bpp, ...);
__declspec (dllexport) int UVImage_getXSize(CImage *img, ...);
__declspec (dllexport) int UVImage_getYSize(CImage *img, ...);
__declspec (dllexport) int UVImage_getBPP(CImage *img, ...);
__declspec (dllexport) int UVImage_destroy(CImage *img, ...);
__declspec (dllexport) int UVImage_setRGB(CImage *img, int x, int y, BYTE r, BYTE g, BYTE b, ...);
__declspec (dllexport) int UVImage_setRGB2(CImage *img, int x, int y, COLORREF rgb, ...);
__declspec (dllexport) int UVImage_setR(CImage *img, int x, int y, BYTE r, ...);
__declspec (dllexport) int UVImage_setG(CImage *img, int x, int y, BYTE g, ...);
__declspec (dllexport) int UVImage_setB(CImage *img, int x, int y, BYTE r, ...);
__declspec (dllexport) int UVImage_setGR(CImage *img, int x, int y, BYTE gr, ...);
__declspec (dllexport) BYTE UVImage_getR(CImage *img, int x, int y, ...);
__declspec (dllexport) BYTE UVImage_getG(CImage *img, int x, int y, ...);
__declspec (dllexport) BYTE UVImage_getB(CImage *img, int x, int y, ...);
__declspec (dllexport) BYTE UVImage_getL(CImage *img, int x, int y, ...); //Returns L item (lightness) from HLS color model...
__declspec (dllexport) int UVImage_getCol(CImage *img, COLORREF *col, int x, ...); //Functions copying whole column or row (target buffer must be large enought to hold data!)
__declspec (dllexport) int UVImage_getRow(CImage *img, COLORREF *row, int y, ...);
__declspec (dllexport) int UVImage_setPenColor2(CImage *img, COLORREF rgb, ...); //Sets pencolor
__declspec (dllexport) int UVImage_setLineRGB(CImage *img, int line, BYTE *row, int pixels, ...); //Sets line's RGB-triples bytes
__declspec (dllexport) int UVImage_setLineRGB2(CImage *img, int line, COLORREF *row, int pixels, ...);
//-------------Copy functions-------------
//This functions simply copies CImage to target CImage, doesn't perform any special operations even if target CImage is smaller than source (target will be croped)
__declspec (dllexport) int UVImage_copyTo(CImage *img, CImage* timg, int xp, int yp, ...);
//This functions copies CImage to target CImage, if the target CImage is too small, size of target CImage will be increased
__declspec (dllexport) int UVImage_copyTo_enlargetarget(CImage *img, CImage* timg, ...);
//This functions copies CImage to target CImage and changes it's size to target's CImage size (will perform resample size)
__declspec (dllexport) int UVImage_scaleTo(CImage *img, CImage* timg, ...);
//This functions copies CImage to target and changes it's size so it will be copied as 'thumbnail' - will have the same x:y ratio and it will be in maximal target picture size (CImage will be centered in area of target CImage which has imaginary bx*by border)
__declspec (dllexport) int UVImage_thumbnailTo(CImage *img, CImage* timg, int bx, int by, int border, int useresample, ...);
//-------------CImage effects-------------
//This function resizes CImage to selected size
__declspec (dllexport) int UVImage_resize(CImage *img, int newx, int newy, int rtype, int rfilter, int blur, ...);
//This function changes color depth of CImage, onebppparam is currently used as parameter for hilbert filter
__declspec (dllexport) int UVImage_quantize(CImage *img, int newcolors, int filter, int onebppparam, int xbppparam1, int xbppparam2, int cttype, ...);
//Creates color table for CImage
__declspec (dllexport) int UVImage_colortable_make(CImage *img, ...);
//Returns count of colortable items
__declspec (dllexport) int UVImage_colortable_itemscount(CImage *img, ...);
//Frees color table (it's automatically called by destructor, but you should use it explicitly to free memory)
__declspec (dllexport) int UVImage_colortable_free(CImage *img, ...);
//These functions are testing, whether colortable is truecolor, greyscale, B/W or colormapped
__declspec (dllexport) int UVImage_colortable_isgreyscale(CImage *img, ...);
__declspec (dllexport) int UVImage_colortable_isblackwhite(CImage *img, ...);
__declspec (dllexport) int UVImage_colortable_istruecolor(CImage *img, ...);
__declspec (dllexport) int UVImage_colortable_iscolormapped(CImage *img, ...);
//Returns colortable items (colors array must be large enought to hold data), you can specify maxbpp to limit maximal count of colors returned
__declspec (dllexport) int UVImage_colortable_get(CImage *img, COLORREF colors[], int maxbpp, ...);
//Returns index of specified color in colortable or -1 if this color doesn't exist in
__declspec (dllexport) int UVImage_colortable_lookupcolor(CImage *img, BYTE r, BYTE g, BYTE b, long *count, ...);
__declspec (dllexport) int UVImage_colortable_lookupcolor2(CImage *img, COLORREF c, long *count, ...);
//DANGEROUS: Sets colormap for CImage from COLORREF table with lenght 'len'. Be sure it's the right colortable, otherwise, CImage class will do strange things!
__declspec (dllexport) int UVImage_colortable_set(CImage *img, COLORREF table[], int len, ...);
//DANGEROUS: Sets index of specified color and validates other indexes...
__declspec (dllexport) int UVImage_colortable_setcolorindex(CImage *img, BYTE r, BYTE g, BYTE b, int index, ...);
__declspec (dllexport) int UVImage_colortable_setcolorindex2(CImage *img, COLORREF c, int index, ...);
//Specific filters for color quantizing. Used by quantize method
__declspec (dllexport) int UVImage_quantize_1bpp_epox1(CImage *img, ...);
__declspec (dllexport) int UVImage_quantize_1bpp_epox2(CImage *img, ...);
__declspec (dllexport) int UVImage_quantize_1bpp_epox3(CImage *img, ...);
__declspec (dllexport) int UVImage_quantize_1bpp_epox4(CImage *img, ...);
__declspec (dllexport) int UVImage_quantize_1bpp_epox5(CImage *img, ...);
__declspec (dllexport) int UVImage_quantize_1bpp_other(CImage *img, int type, int hilbertp, ...);
__declspec (dllexport) int UVImage_quantize_xbpp(CImage *img, int newcolors, int filter, int type1, int type2, int cttype, ...);
//This function erases whole CImage with color specified with 'color' parameter
__declspec (dllexport) int UVImage_clear(CImage *img, COLORREF color, ...);
//Fills selection of CImage with current pen color
__declspec (dllexport) int UVImage_fill(CImage *img, COLORREF color, ...);
__declspec (dllexport) int UVImage_fill2(CImage *img, ...);
//Draws rect with specified color (uses selection)
__declspec (dllexport) int UVImage_drawRect(CImage *img, COLORREF color, ...);
//This function loads specified file if possible (if filters for specified file type are available) - automatically recognizes input format (by RAW, YUV and ICO it uses settings of UniView - use specific functions to control loading parameters (open_raw, open_yuv, open_ico))
__declspec (dllexport) int UVImage_load(CImage *img, char *path, ...);
//This function saves specified file if possible (if filters for specified file type are available) - automatically recognizes target format and uses settings of UniView to set files' properties (use specific functions to modify)
__declspec (dllexport) int UVImage_save(CImage *img, char *path, char *extuse, ...);
//-------------Service functions-------------
//Functions to give CImage's internal data (please don't do any sh*t with these pointers)
__declspec (dllexport) int UVImage_effect_3dbutton(CImage *img, int butx, int buty, int graybutton, ...);
//Dims current selection using strength parameter as intensity
__declspec (dllexport) int UVImage_effect_dim(CImage *img, int strength, ...);
//Creates mirror of CImage
__declspec (dllexport) int UVImage_effect_flip(CImage *img, ...);
//Creates top-bottom switched CImage
__declspec (dllexport) int UVImage_effect_flop(CImage *img, ...);
//Rotates CImage left
__declspec (dllexport) int UVImage_effect_rotateleft(CImage *img, ...);
//Rotates CImage right
__declspec (dllexport) int UVImage_effect_rotateright(CImage *img, ...);
//Isolates selected color (prm. which) and, optionally shows this channel in color mode
__declspec (dllexport) int UVImage_effect_isolatecolor_rgb(CImage *img, int which, int togray, ...);
//Isolates selected component of HSV model of CImage
__declspec (dllexport) int UVImage_effect_isolatecolor_hsv(CImage *img, int which, ...);
//Converts CImage from RGB to other CImage channel order (each parameter specifies new position of component, zero-based - eg. if newri=2, newgi=1, newbi=0, CImage will be BGR)
__declspec (dllexport) int UVImage_effect_rgbto(CImage *img, int newri, int newgi, int newbi, ...);
//Creates negative of CImage
__declspec (dllexport) int UVImage_effect_negative(CImage *img, ...);
//Replaces greyscale colors with color
__declspec (dllexport) int UVImage_effect_replacegrey(CImage *img, int tolerance, COLORREF pencolor, ...);
//Creates gray CImage using algorithm C=(R+G+B)/3 for each pixel
__declspec (dllexport) int UVImage_effect_makegray_sum(CImage *img, ...);
//Creates gray CImage using lightness value of HSV color model (it's faster then HSV isolating, but it's less sophisticated...)
__declspec (dllexport) int UVImage_effect_makegray_light(CImage *img, ...);
//Changes color attributes of CImage (first three pars. are changing RGB, next three HSV and last gamma values of pixel)
__declspec (dllexport) int UVImage_effect_enhance_colors(CImage *img, int retr, int retg, int retb, int reth, int rets, int retv, double gamma, ...);
//Makes pixelized CImage with boxx*boxy size boxes
__declspec (dllexport) int UVImage_effect_pixelize(CImage *img, int boxx, int boxy, ...);
//Exploses CImage using matrixx*matrixy size matrix and seed parameter as strength
__declspec (dllexport) int UVImage_effect_explosion(CImage *img, int matrixx, int matrixy, int seed, ...);
//Finds edges in CImage
__declspec (dllexport) int UVImage_effect_findedges(CImage *img, ...);
//Makes details more visible by strenght factor
__declspec (dllexport) int UVImage_effect_enhance(CImage *img, int strenght, ...);
//Makes CImage like it were slopped by some liquid
__declspec (dllexport) int UVImage_effect_slopedcolors(CImage *img, ...);
//Makes 'oilpaint work' from CImage
__declspec (dllexport) int UVImage_effect_oilpaint(CImage *img, int bublesize, ...);
//Embosses CImage
__declspec (dllexport) int UVImage_effect_emboss(CImage *img, int azimuth, int elevation, int width, ...);
//Noises CImage
__declspec (dllexport) int UVImage_effect_noise(CImage *img, int intensity, int colornoise, int additive, int strenght, ...);
//Interlaces CImage
__declspec (dllexport) int UVImage_effect_interlace(CImage *img, int stepx, int stepy, int offsetx, int offsety, int type, COLORREF pencolor, ...);
//Shakes CImage
__declspec (dllexport) int UVImage_effect_shake(CImage *img, COLORREF color, ...);
//Custom matrix-defined effect
__declspec (dllexport) int UVImage_effect_custom(CImage *img, int vals[49], int div, int bias, ...);
//Makes gradient in CImage
__declspec (dllexport) int UVImage_effect_gradient(CImage *img, int type, COLORREF color1, COLORREF color2, ...);
//Blurs CImage like it was moved fast
__declspec (dllexport) int UVImage_effect_motionblur(CImage *img, int direction, int step, int stepcount, ...);
//Blurs CImage
__declspec (dllexport) int UVImage_effect_blur(CImage *img, int strenght, ...);
//Applies decolorify effect to CImage
__declspec (dllexport) int UVImage_effect_decolorify(CImage *img, int maxc, ...);
//Applies median filter to CImage
__declspec (dllexport) int UVImage_effect_medianfilter(CImage *img, int radius, ...);
//Changes contrast of CImage
__declspec (dllexport) int UVImage_effect_contrast(CImage *img, int strenght, ...);
//Applies threshold effect to CImage
__declspec (dllexport) int UVImage_effect_threshold(CImage *img, int value, COLORREF c1, COLORREF c2, ...);
#if (CIMAGEVER>=1800)
//Blends img2 with img
__declspec (dllexport) int UVImage_effect_alphablendwith(CImage *img, CImage *img2, int alpha, int x, int y, int x1, int y1, int xs, int ys, int transparent, COLORREF transcolor, ...);
//Rotates image
__declspec (dllexport) int UVImage_rotate(CImage *img, float angle, int antialias);
//Crops image
__declspec (dllexport) int UVImage_crop(CImage *img, int xs, int ys, COLORREF bkcolor, int align);
//Replaces one color to another
__declspec (dllexport) int UVImage_effect_replaceColor(CImage *img, COLORREF incolor, COLORREF outcolor, int intolerance, int transformcolors);
#endif
#ifdef __cplusplus
__declspec (dllexport) int UVImage_quantize(CImage *_img, int newcolors, int filter, int onebppparam=1, int xbppparam1=1, int xbppparam2=2, int cttype=0, ...);
__declspec (dllexport) int UVImage_thumbnailTo2(CImage *_img, CImage& timg, int bx=0, int by=0, int border=1, int useresample=0, ...);
__declspec (dllexport) int UVImage_thumbnailTo(CImage *_img, CImage* timg, int bx=0, int by=0, int border=1, int useresample=0, ...);
__declspec (dllexport) int UVImage_resize(CImage *_img, int newx, int newy, int rtype=0, int rfilter=0, int blur=1, ...);
__declspec (dllexport) int UVImage_copyTo(CImage *_img, CImage* timg, int xp=0, int yp=0, ...);
__declspec (dllexport) int UVImage_colortable_get(CImage *_img, COLORREF colors[], int maxbpp=8, ...);
__declspec (dllexport) int UVImage_colortable_lookupcolor(CImage *_img, BYTE r, BYTE g, BYTE b, long *count=NULL, ...);
__declspec (dllexport) int UVImage_colortable_lookupcolor2(CImage *_img, COLORREF c, long *count=NULL, ...);
__declspec (dllexport) int UVImage_quantize_1bpp_other(CImage *_img, int type, int hilbertp=1, ...);
__declspec (dllexport) int UVImage_quantize_xbpp(CImage *_img, int newcolors, int filter, int type1=1, int type2=2, int cttype=0, ...);
__declspec (dllexport) int UVImage_effect_addimage(CImage *_img, CImage &tmp, int xs=0, int ys=0, int alpha=100, ...);
__declspec (dllexport) int UVImage_effect_gradient(CImage *_img, int type, COLORREF color1=RGB(0, 0, 0), COLORREF color2=RGB(255, 255, 255), ...);
__declspec (dllexport) int UVImage_effect_isolatecolor_rgb(CImage *_img, int which, int togray=0, ...);
__declspec (dllexport) int UVImage_save(CImage *_img, char *path, char *extuse=NULL, ...);
__declspec (dllexport) int UVImage_effect_addimage(CImage *img, CImage &tmp, int xs, int ys, int alpha, ...);
__declspec (dllexport) int UVImage_scaleTo2(CImage *img, CImage& timg, ...);
__declspec (dllexport) int UVImage_copyRectTo(CImage *img, int x, int y, int xs, int ys, CImage &timg, int tx, int ty, ...);