Commit Graph

30 Commits

Author SHA1 Message Date
Adam Thomason 874f89dba4 Don't resize inputs with zero width or height
Inputs having zero as both width and height were caught, but either one
alone caused a panic. This adds a test showing the old failing behavior
and adds a check for non-positive width/height. Since Resize doesn't
have an error return value, the behavior in this case is to return the
original image.

Fixes https://github.com/nfnt/resize/issues/52
2016-11-15 15:47:54 -08:00
nfnt 0f9f918da3 Use RGBA, RGBA64 image types as output.
These image types use premultiplied alpha values which are also used during the interpolation. If we'd use NRGBA, NRGBA64 as output, we'd have to reverse the premultiplication.
2016-01-07 21:30:54 +01:00
nfnt 579058ccc0 Test for color-casts due to wrong alpha-channel scaling. 2016-01-07 20:34:21 +01:00
minodisk 87f723015c Test same color with some color modes 2015-05-25 18:53:05 +09:00
minodisk f430a41192 Fix wrong color with RGBA input 2015-05-25 18:20:03 +09:00
nfnt f2d1b73023 Merge branch 'alpha_channel_fix'
Colors in image.RGBA, image.RGBA64 and generic types with alpha channel should
now resize correctly. There's a small performance hit for these image types even
if they don't use alpha channels though.
Fixes bug #26.
2015-05-12 16:00:13 +02:00
nfnt 563154816f Remove debugging directives. 2015-05-12 15:24:41 +02:00
nfnt 5a6676c19e Add test case for input data with pre-multiplied-alpha. 2015-05-12 15:18:07 +02:00
jst 618f7ff07a Add test case for correct pixel coordinates after resize. 2015-03-27 19:48:18 +01:00
Charlie Vieth b09281bd36 Update benchmarks to focus on conversion performance.
Benchmark each interpolation function for RGBA and YCbCr images.
Reduce the image size used when benchmarking to reduce the influence of
memory performance on results.
2015-03-15 17:40:38 -04:00
jst 9485f5475a Return input image if output dimensions equal input dimensions. 2014-12-17 11:10:53 +01:00
jst 20c6afea04 Remove unnecessary benchmark 2014-09-15 11:58:05 +02:00
jst 220cad3343 Add simple test case for input image with non-trivial bounds. 2014-08-13 20:12:18 +02:00
jst 016a61cd31 Optimize data-locality for a huge increase in processing speed.
This is a complete rewrite! The tight scaling loop needs data locality for optimal performance. The old version used lots of pointer redirections to access image data which was bad for data locality. By providing the complete loop for each image type, this problem is solved. Unfortunately this increases code duplication but the result should be worth it: I could measure a ~6x speed-up for certain test cases!
2014-07-19 13:19:31 +02:00
jst 446eea2f7b Remove LUT based filters.
Caching kernel weights makes using the LUT based approach obsolete. Now they seem to be even slower than their counterparts.
2014-01-28 18:54:57 +01:00
jst 8f586c4f06 Add benchmarks to compare execution times.
Run "go test -bench LargeJpegThumb" to benchmark all functions at once.
2014-01-18 11:55:34 +01:00
jst 252ccc84a2 Add benchmarks for Lanczos3Lut to compare it with Lanczos3 performance. 2013-07-08 20:55:46 +02:00
jst da95f74904 go fmt 2013-03-10 11:55:50 +01:00
jst 852f4a47e7 Merge branch 'no-image-shift' of http://github.com/jsummers/nfnt.resize
Merge branch 'fix-canvas-size-issue'
2013-03-10 11:33:44 +01:00
jst 84039c403b Test for correct canvas size. 2013-03-10 10:58:08 +01:00
Jason Summers 3d9094eb9e Center the resized image on the canvas, instead of shifting it slightly 2012-11-27 20:38:19 -05:00
jst 3e06045c3f Speed up computation: Try to avoid Image.At() as much as possible -> specialized color access for some image types 2012-09-21 20:02:25 +02:00
jst e548f52385 Blur input image during downscaling by scaling the filter kernel to prevent moires in the output image 2012-09-19 21:03:56 +02:00
jst d0b2b9bc39 Added MitchellNetravali, changed Lanczos a bit 2012-09-19 19:32:00 +02:00
jst 3fc31c95cc Kernel simplified 2012-09-15 19:30:32 +02:00
jst 339b8fd43a Speed up calculation by avoiding dynamic casting 2012-09-01 00:21:10 +02:00
jst 9041d4db18 Function signature changed again, no need for multiple return value 2012-08-09 18:58:57 +02:00
jst 14d51db8b4 Changed function signature to include error handling. Filters simplified. 2012-08-08 21:32:51 +02:00
nfnt fdc4a64918 Tests added 2012-08-03 18:12:26 +02:00
nfnt 428642c9f1 initial commit 2012-08-02 21:59:40 +02:00