Giter Site home page Giter Site logo

fl_imgtk's Introduction

(lib)fl_imgtk

  • A small library for FLTK image toolkit.
  • Designed to use some useful effects in FLTK GUI.
  • Better image, better speed, better quality.

Lastest update

  • 2021-05-24
    1. Now supporting 1 or 2 depth Fl_RGB_Image.
    2. Version updated to 0.3.40.30
    3. debugging required

Previous updates

  • 2021-05-17
    1. Fixed rotate180() only woks for depth 3 (RGB bug fixed)
    2. Fixed invert() works for alpha channel (RGBA bug fixed)
    3. Fixed Reinhard affected by alpha channel.
    4. Version updated to 0.3.39.27
  • 2021-05-11
    1. Reinhard tone mapping OpenMP performance issue fixed, now 10x faster than before.
    2. Version updated to 0.3.39.25
    3. notice: g++ OpenMP must be supported reduction().
  • 2021-02-08
    1. Fixed tone mapping images not returns with FLIMGTK_IMGBUFF_OWNALLOC flag.
    2. Fixed Drago (Logmapping) HDR color correction issue.
    3. Version updated to 0.3.38.21
  • 2021-01-21
    1. Fixed some OpenMP errors, ehanced for compatibility.
    2. Fixed error of flipping.
    3. Replaced draw smooth line algorithm to "SDF optimization with AABB".
    4. Some detour inline functions for MSVC ...
    5. Version updated to 0.3.37.16
  • 2021-01-20
    1. Some enhancements for MSVC OpenMP compatibility.
    2. Fixed drawing polygon errors in alpha-depth RGB buffer.
    3. Fixed typo error in OpenMP, also fixed OpenMP compatibilities including tonemaps and CLAHE.
    4. All created Fl_RGB_Image now alloc_array member set to 1 by FLIMGTK_IMGBUFF_OWNALLOC flag.
    5. Now it should be safe by call delete instead using discard_user_rgb_image().
    6. MSVC OpenMP only availed for Release. ( changing project is own-risk, it doesn't made for MSVC )
    7. Still smooth_line has some thickness error by starting x1 less than x2 coordination.
    8. Version updated to 0.3.37.12
  • 2020-12-15-1
    1. Fixed color space error on drago HDR.
    2. Version updated to 0.3.35.8
  • 2020-04-28-1
    1. Fixed some alpha depth processing routines.
    2. No Fl_Color, use unsigned long for RGBA.
    3. New feature, draw_smooth_line_ex() included.
    4. Version updated to 0.3.35.7
  • 2019-04-23-2
    1. New feature, draw_rect() and draw_fillrect() included.
    2. Version updated to 0.3.32.0
  • 2019-04-23-1
    1. Little bug fixed in drawing simple line
    2. Version updated to 0.3.31.2
  • 2019-04-22-1
    1. Little changes in drawing smooth line.
    2. removed non-affective OpenMP preprocessors.
    3. Version updated to 0.3.31.1
  • 2018-03-26-1
    1. Fixed a bug of image merging.
    2. fl_drawonimage supports both of rgb and rgba images.
    3. Version updated to 0.3.31.0
  • 2018-03-21-1
    1. Fixed a bug occurs black line when it turns image to 90 or 240.
    2. Version updated to 0.3.30.6
  • 2018-02-02-1
    1. Fixed bugs in rotate free to use right degree in 0 to 359.
    2. Version updated to 0.3.30.5
  • 2017-11-30-1
    1. Fixed bugs in draw_line() and draw_smoothline().
    2. Still left a bug in draw_smoothline() rounding error of y2 coordination.
    3. Version updated to 0.3.30.3
  • 2017-11-14-1
    1. Fixed a bug in applyaplha_ex().
    2. VisualStudio 2015 project builds target for static build.
    3. Version updated to 0.3.30.2
  • 2017-11-02-1
    1. Included a drawing function for single line (not aliased)
    2. Version updated to 0.3.30.1
  • 2017-10-30-2
    1. Enhanced to OpenMP error for reinhard HDR, but running speed gone for slower.
    2. Version updated to 0.3.27.2
  • 2017-10-30-1
    1. Fixed a bug of color order of makeanempty();
    2. Version updated to 0.3.27.1
  • 2017-10-13-2
    1. Fixed SIGTRAP occurs when try remove Fl_RGB_Image buffer from got draw_currentwindow();
    2. It seems to a bug of FLTK, by fl_read_image().
    3. Version updated to 0.3.26.2
  • 2017-10-13-1
    1. Changed sens bit depth in makegradation_h and v.
    2. Version updated to 0.3.26.1
  • 2017-10-12-1
    1. Fixed a wrong method name, "brightbess_ex" to "brightness_ex".
    2. Added new function for "draw_currentwindow()".
    3. draw_smoothline() now controls with alpha channel.
    4. Version updated to 0.3.26.0
  • 2017-10-11-1
    1. New method : createBMPmemory(), for create new BMP image from memory.
    2. Version updated to 0.3.25.1
  • 2017-08-14-1
    1. New method : makeanempty(), for create new image.
  • 2017-08-14-0
    1. Updated header for drawonimage method.
    2. drawonimage condition changed for alpha channel.
  • 2017-08-10-0
    1. Fixed bugs in makegradation_h and v methods.
    2. Now makegradation_h/v() methods support alpha channel.
  • 2017-07-27-0
    1. OpenMP applied drawing to
      • smooth line.
      • polygon.
  • 2017-07-26-0
    1. New functions included !
      • drawing smooth line.
        • drawing polygon.
  • 2017-04-19-0
    1. Fixed wrong pointer addressing in
      • CLAHE();
      • CLAHE_ex();
    2. Added new effect belong to CLAHE.
      • noire();
      • noire_ex();
  • 2017-04-18-0
    1. Added a feature
      • CLAHE();
      • CLAHE_ex();
  • 2017-04-06-0
    1. Bug fixed
      • applyalpha_ex();
  • 2017-04-05-0
    1. New feature
      • invert();
      • invert_ex();
  • 2017-03-31-0
    1. New features
      • makegradation_h();
      • makegradation_v();
    • 2017-03-30-0
      1. New features
        • FL_IMGTK, FL_IMGTK_VERSION definitions
        • fliphorizontal_ex();
        • flipvertical_ex();
        • gamma_ex();
        • brightbess_ex();
        • contrast_ex();
        • blurredimage_ex();
        • filtered_ex();
        • tonemapping_reinhard_ex();
        • tonemapping_drago_ex();
        • subtract();
        • sbutract_ex();
        • applyalpha_ex();
    • 2017-03-29-0
      1. Now supports many drawing image functions.
        • merge();
        • makealphamap();
        • applyalpha();
        • drawonimage();
  • 2017-03-28-0
    1. Cropping image to a new Fl_RGB_Image.
    2. Fixed bugs on Tone mapping (HDR), now it runs well for Drago and Reinhard algorithms.
  • 2017-03-24-0
    1. First commit.
    2. Supporting LLVM-gcc for Apple Mac.

How to build ?

  • Just make a symbolic link from your subsystem
    • ln -s Makefile.gcc Makefile
  • MinGW-W64 or MSYS2 may need to copy Makefile.mingw to Makefile.
    • Eg) MinGW-W64 need do cp Makefile.mingw Makefile
  • Then make
  • Or you can use make -f Makefile.xxx

Currently supported

  • OpenMP 3.0 or higher version of gcc, or supported compiler.
    • Notice: M$ Visual Studio not supports unsigned for() loop.
  • Flip Fl_RGB_Image to horizental or vertical.
  • Rotate Fl_RGB_Image to these :
    1. 90, 180, 270 degrees.
    2. Or free degree rotate
  • Fast rescale with fl_smimg, with supporting these:
    1. Box(nearest)
    2. Bilinear
    3. Bicubic
    4. Lanczos
    5. B-Spline
    6. ( and more )
  • Draw Fl_Widget to Fl_RGB_Image.
  • Draw Fl_Widget to blurred Fl_RGB_Image.
    • may useful to make background image.
  • Tone mappings (HDR)
    1. DRAGO algorithm.
    2. REINHARD algorithm.
  • RGB-Color CLAHE ( eCLAHE )
  • Kernel matrix filter ( 3x3 to NxN )
  • Crop Fl_RGB_Image to a new Fl_RGB_Image.
  • Merge two different Fl_RGB_Images to a new one.
  • Make alpha map, and apply to Fl_RGB_Image.
  • Draw Fl_RGB_Image to Fl_RGB_Image, it is same like Mix.
  • Subtracts two Fl_RGB_Image.
  • Make gradation image col1 to col2.

Planned to next features

  • RGB Channel mixing
  • White balancing ( auto, manual )

OpenMP supports

  • fl_imgtk designed for OpenMP 3.x or latest,
  • Some less version of OpenMP cause of build error, or lower performance as lik M$VC.
  • Apple Mac, X-Code may not supports OpenMP, recommend to use HPC-GCC to build library. Apple don't need optimizing OpenMP, it's so faster than OpenMP with HPC-GCC in Apple silicon M1. Use Apple M1 !
  • To disable using OpenMP, remove -DUSING_OMP and -fopenmp in your customized Makefile.

Supported compiler:

  • gcc, MinGW-W64 ( with OpenMP )
  • llvm-gcc (Apple) x86.64, arm64 ( automatically generates universal binary if your subsystm is arm64 )
  • M$VC with some limited OpenMP ( I don't have plan to use concurrency )

External licenses:

  • FreeImage 3 (many algorithms belongs to this)
  • FLTK License

fl_imgtk's People

Contributors

rageworx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

pdhahn

fl_imgtk's Issues

fl_imgtk::rescale crashing with SVG

Testing in YAIV.

Load firefox_logo_2017.svg
Use 's' or up/down arrow keys to change zoom to something besides 100%.
Use 'z' key to change imgTk scaling method.

SIGSEGV in ResizeEngine::horizontalFilter

It's the end of my day otherwise I'd have dug into it further.

Problems observed while using fl_imgtk::crop

I will be looking at using other bits of code soon, but here are some problems I discovered after grabbing the crop function. My thanks in advance for these functions!

  1. Perhaps you have a macro in your headers someplace, but this: #pragma omp parellel should be "parallel".
  2. I'm occasionally encountering images which are very large. You might consider using size_t to calculate the size of obuff.
  3. This following chunk of code leaks obuff if rbuff is NULL.
        uchar* rbuff = (uchar*)src->data()[0];
        uchar* obuff = new uchar[ rw * rh * sd ];

        if ( ( rbuff != NULL ) && ( obuff != NULL ) )
  1. This might a limitation of Microsoft's OMP implementation, but it complains the cntx and cnty loop variables need to be signed objects in the parallel for loops.
  2. Something which I think is inadequately documented is the fact that the Fl_RGB_Image destructor does not free the memory buffer automatically. The programmer has to manually set the field alloc_array to non-zero, otherwise the buffer is leaked. So:
		return new Fl_RGB_Image(obuff, rw, rh, sd);

really should be:

		Fl_RGB_Image* retimg = new Fl_RGB_Image(obuff, rw, rh, sd);
                retimg->alloc_array = 1;
		return retimg;

Supporting Fl_RGB_Image depth 1, and 2.

I seems to need supporting single Y channel and Y+alpha channel ( depth 2 ) of Fl_RGB_Image.
Someone may love this feature for making some special viewer.

  • additional ref. #16

Disposing of "rescaled" image may result in crash

I'm trying out fl_imgtk::rescale. I noticed inside ResizeEngine::scale that if the requested size was unchanged from the original, then a copy of the original is returned:

    if ( ( src->w() == dst_width) && ( src->h() == dst_height))
    {
        return (Fl_RGB_Image*)src->copy();
    }

As I expected in this scenario, calling discard_user_rgb_image on the rescaled image caused a crash. As the returned image in this case is not allocated by fl_imgtk.

This means the caller of fl_imgtk::rescale needs to write code to know when to call discard_user_rgb_image or not. [Of course, they should have written code to not call rescale in this scenario ...]

I'm thinking it might be better to return NULL in this situation?

[And my thanks for this library, I'm definitely using the rotate/flip functions, loving the performance!]

smooth line error.

It will occurs with this condition.

  • x1 is less than x2.
  • y1 is less than y2.
  • thickness more than 3.f.
    image

Rotate180 may be hard-coded for 24-bit

I've been having some problems with rotate180.

  1. Images of depth 4 (e.g. PNG with transparency), the transparent bits aren't rotated properly.
  2. Images of depth 1 seem to result in a memory corruption crash when displayed.

I believe these lines:

            fl_imgtk_swap_mem( &buff[ cnt * d ],
                               &buff[ (imgmax - cnt - 1) * d ],
                               3);

should be:

            fl_imgtk_swap_mem( &buff[ cnt * d ],
                               &buff[ (imgmax - cnt - 1) * d ],
                               d);

I.e. not hard-coding 24 bits of image depth.

Here is a depth 1 PNG file:
3016021.png.zip

And here is a depth 4 PNG:
19000.png.zip

[HELP] undefined reference error

even I use in my actual code I get same error
library is compiled using g++

$ cat test.cpp

#include "/home/oggy/projects/PicMe/fl_imgtk/lib/fl_imgtk.h"
#include <FL/Fl_PNG_Image.H>
int main(){
  Fl_PNG_Image* img = new Fl_PNG_Image("/home/oggy/Pictures/Square_200x200.png");
  fl_imgtk::rotate90(img);
}

$ g++ -lfltk -lfltk_images -std=c++11 -L /home/oggy/projects/PicMe/fl_imgtk/lib -l fl_imgtk test.cpp

/usr/bin/ld: /tmp/ccVPeWoH.o: in function `main':
test.cpp:(.text+0x3e): undefined reference to `fl_imgtk::rotate90(Fl_RGB_Image*)'
collect2: error: ld returned 1 exit status

Reinhard may not effective for OpenMP.

One of tone mapping, Reinhard algorithm took some strange result by testing performance.

Tested 5790x8688 JPEG image at Intel i7-7700 ( 3.6GHz ), Windows 10 x86.64

First, with OpenMP. ( CPU going to 100% usage )
image
about 27 seconds.

Then with non-OpenMP. ( much less CPU usage ... )
image
about 15 seconds.

Hmm ??? Need more test ...
library compiled with MinGw-W64 gcc 10.2.0(rev9).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.