Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

ImageStone - A Powerful C++ Class Library for Image Manipulation

, 6 Dec 2011 Zlib
An article on a library for image manipulation
imagestonesrc.zip
ImageStone
example
001
src
001.dsp
001.dsw
Makefile
002
src
002.dsp
002.dsw
002.ico
bk.tga
small.ico
003
src
003.dsp
003.dsw
003.ico
rgn.TGA
small.ico
004
src
004.dsp
004.dsw
005
src
005.dsp
005.dsw
Makefile
006
src
006.dsp
006.dsw
Makefile
007
src
007.dsp
007.dsw
Makefile
008
src
008.dsp
008.dsw
res
008.exe.manifest
008.ico
008Doc.ico
arc_grad.bmp
tex_canvas.BMP
Toolbar.bmp
009
src
009.dsp
009.dsw
009.ico
pattern.jpg
small.ico
010
src
010.dsp
010.dsw
010.plg
res
010.ico
include
command
imagefile
pixelprocessor
lib
FreeImage
Dist
Source
gdiplus
Include
lib
imagestone_chm.zip
doc.chm
imagestone_demo.zip
002_vs2005.exe
imagestone_demo008.zip
008.exe
imagestone_demo_008.zip
008.exe
imagestone_docchm.zip
Help.chm
imagestone_doc_chm.zip
index.chm
imagestone_doc_html.zip
doc_html
doxygen.png
class_f_c_image_handle.png
class_f_c_image_handle___bmp.png
class_f_c_image_handle___free_image.png
class_f_c_image_handle___gdiplus.png
class_f_c_image_handle___i_picture.png
class_f_c_image_handle___tga.png
class_f_c_image_handle_base.png
class_f_c_image_handle_factory.png
class_f_c_image_handle_factory___i_picture.png
class_f_c_image_handle_factory___mini.png
class_f_c_interface___pixel_process.png
class_f_c_object.png
class_f_c_obj_graph.png
class_f_c_obj_image.png
class_f_c_obj_multi_frame.png
class_f_c_pixel3_d_grid.png
class_f_c_pixel_add_random_noise.png
class_f_c_pixel_adjust_r_g_b.png
class_f_c_pixel_auto_color_enhance.png
class_f_c_pixel_auto_contrast.png
class_f_c_pixel_bilinear_distord.png
class_f_c_pixel_blinds.png
class_f_c_pixel_brightness.png
class_f_c_pixel_color_balance.png
class_f_c_pixel_color_level.png
class_f_c_pixel_colors_count.png
class_f_c_pixel_color_tone.png
class_f_c_pixel_combine_channel___r_g_b.png
class_f_c_pixel_contrast.png
class_f_c_pixel_convert_quantize.png
class_f_c_pixel_convert_to16_bit.png
class_f_c_pixel_convert_to8_bit_gray.png
class_f_c_pixel_convolute.png
class_f_c_pixel_cylinder.png
class_f_c_pixel_deinterlace.png
class_f_c_pixel_detect_edges.png
class_f_c_pixel_emboss.png
class_f_c_pixel_export_asc_i_i.png
class_f_c_pixel_fill3_d_solid_frame.png
class_f_c_pixel_fill_color.png
class_f_c_pixel_fill_grid.png
class_f_c_pixel_flip.png
class_f_c_pixel_fractal_trace.png
class_f_c_pixel_gamma.png
class_f_c_pixel_gaussian_blur3x3.png
class_f_c_pixel_gaussian_blur5x5.png
class_f_c_pixel_get_key_color.png
class_f_c_pixel_gradient_base.png
class_f_c_pixel_gradient_bi_line.png
class_f_c_pixel_gradient_conical_a_sym.png
class_f_c_pixel_gradient_conical_sym.png
class_f_c_pixel_gradient_line.png
class_f_c_pixel_gradient_radial.png
class_f_c_pixel_gradient_rect.png
class_f_c_pixel_grayscale.png
class_f_c_pixel_halftone_m3.png
class_f_c_pixel_hue_saturation.png
class_f_c_pixel_illusion.png
class_f_c_pixel_invert.png
class_f_c_pixel_lens.png
class_f_c_pixel_l_u_t_routine.png
class_f_c_pixel_median_filter.png
class_f_c_pixel_mirror.png
class_f_c_pixel_mosaic.png
class_f_c_pixel_noisify.png
class_f_c_pixel_oil_paint.png
class_f_c_pixel_perspective.png
class_f_c_pixel_posterize.png
class_f_c_pixel_ribbon.png
class_f_c_pixel_ripple.png
class_f_c_pixel_rotate.png
class_f_c_pixel_rotate270.png
class_f_c_pixel_rotate90.png
class_f_c_pixel_sharp.png
class_f_c_pixel_shift.png
class_f_c_pixel_skew.png
class_f_c_pixel_small_tile.png
class_f_c_pixel_solarize.png
class_f_c_pixel_splash.png
class_f_c_pixel_splite_channel___r_g_b.png
class_f_c_pixel_threshold.png
class_f_c_pixel_video.png
class_f_c_pixel_wave.png
class_f_c_pixel_whirl_pinch.png
class_f_c_single_pixel_process_base.png
imagestone_src.zip
image_stone
doc
doc.rar
Doxyfile
example
001
Makefile
Readme_MinGW
002
dlg_effect_blinds.inl
dlg_effect_color_balance.inl
dlg_effect_color_level.inl
dlg_effect_color_tone.inl
dlg_effect_custom.inl
dlg_effect_fillgrid.inl
dlg_effect_lensflare.inl
dlg_effect_supernova.inl
dlg_image_size.inl
res
002.ico
002Doc.ico
bar_top.png
example.jpg
lang.ini
menu_icon
adjustrgb.png
brightness_contrast.png
color_balance.png
color_level.png
color_tone.png
effect_fillgrid.png
effect_invert.png
effect_lensflare.png
effect_oil.png
effect_pencil.png
effect_splash.png
effect_supernova.png
effect_twist.png
flip.png
grayscale.png
hue_saturation.png
mirror.png
open.png
print.png
quit.png
resize.png
rotate270.png
rotate90.png
save_as.png
smooth_edge.png
to_ascii.png
shadow.png
tex_bricks.png
tex_canvas_1.png
tex_canvas_2.png
tex_dot.png
tex_grid.png
tex_leather.png
tex_mat.png
tex_sandstone.png
tex_weave.png
uistone
include
effect
image_codec
image_effect.inl
image_property.inl
image_resize_filter.inl
image_win.inl
linux_define.inl
post_implement.inl
//=============================================================================
/**
 *  Tile reflection effect (>=24 bit).
@verbatim
    example:
        FCPixelTileReflection   aCmd (45, 20, 8) ;
        img.SinglePixelProcessProc (aCmd) ;
@endverbatim
 */
class FCPixelTileReflection : public FCSinglePixelProcessBase
{
    struct POINT_FLOAT
    {
        double   x ;
        double   y ;
    };

public:
    /**
     *  Constructor.
     */
    FCPixelTileReflection (int nAngle, int nSquareSize, int nCurvature)
    {
        nAngle = FClamp (nAngle, -45, 45) ;
        m_sin = sin (AngleToRadian(nAngle)) ;
        m_cos = cos (AngleToRadian(nAngle)) ;

        nSquareSize = FClamp (nSquareSize, 2, 200) ;
        m_scale = LIB_PI / (double)nSquareSize ;

        nCurvature = FClamp (nCurvature, -20, 20) ;
        if (nCurvature == 0)
            nCurvature = 1 ;
        m_curvature = nCurvature * nCurvature / 10.0 * (abs(nCurvature)/nCurvature) ;

        for (int i=0 ; i < aasamples ; i++)
        {
            double  x = (i * 4) / (double)aasamples,
                    y = i / (double)aasamples ;
            x = x - (int)x ;
            m_aapt[i].x = m_cos * x + m_sin * y ;
            m_aapt[i].y = m_cos * y - m_sin * x ;
        }
    }
private:
    virtual void OnEnterProcess (FCObjImage* pImg)
    {
        SetBackupImage(pImg) ;
    }
    virtual void ProcessPixel (FCObjImage* pImg, int x, int y, BYTE* pPixel)
    {
        double   hw = pImg->Width() / 2.0,
                 hh = pImg->Height() / 2.0,
                 i = x - hw,
                 j = y - hh ;

        int   b=0, g=0, r=0, a=0 ;
        for (int mm=0 ; mm < aasamples ; mm++)
        {
            double   u = i + m_aapt[mm].x ;
            double   v = j - m_aapt[mm].y ;

            double   s =  m_cos * u + m_sin * v ;
            double   t = -m_sin * u + m_cos * v ;

            s += m_curvature * tan(s * m_scale) ;
            t += m_curvature * tan(t * m_scale) ;
            u = m_cos * s - m_sin * t ;
            v = m_sin * s + m_cos * t ;
            
            int   xSample = (int)(hw + u) ;
            int   ySample = (int)(hh + v) ;

            xSample = FClamp (xSample, 0, GetBackupImage()->Width()-1) ;
            ySample = FClamp (ySample, 0, GetBackupImage()->Height()-1) ;

            BYTE   * p = GetBackupImage()->GetBits(xSample, ySample) ;
            b += PCL_B(p) ;
            g += PCL_G(p) ;
            r += PCL_R(p) ;
            a += PCL_A(p) ;
        }

        PCL_B(pPixel) = FClamp0255 (b / aasamples) ;
        PCL_G(pPixel) = FClamp0255 (g / aasamples) ;
        PCL_R(pPixel) = FClamp0255 (r / aasamples) ;
        PCL_A(pPixel) = FClamp0255 (a / aasamples) ;
    }

    enum
    {
        aasamples = 17,
    };

    double   m_sin, m_cos ;
    double   m_scale ;
    double   m_curvature ;
    POINT_FLOAT   m_aapt[aasamples] ;
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License

Share

About the Author

crazybit
Team Leader PhoXo
China China
graduate from University of Science and Technology of China at 2002.
 
Now I work at www.phoxo.com.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411023.1 | Last Updated 6 Dec 2011
Article Copyright 2006 by crazybit
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid