Commit Graph

71 Commits

Author SHA1 Message Date
Sasha Szpakowski 8c13943f64 ImageData can track whether they're meant to be loaded into a Texture with a non-sRGB format when gamma correct rendering is enabled.
Fixes #1556.

* Add ImageData/CompressedImageData:setLinear and ImageData/CompressedImageData:isLinear.
  The flag is used as a hint when loading a texture from the data to determine if the format should not be treated as sRGB-encoded. The 'linear' flag in newImage overrides this.

* love.graphics.readbackTexture automatically sets the linear flag on ImageData it returns when the texture's format is linear.
  This allows an ImageData generated via readback to be fed back into a new Texture and the format will match the original Canvas.

* Also clean up some image decoding code.
2023-10-14 20:48:21 -03:00
Sasha Szpakowski f6cdbdc868 Merge branch 'main' into 12.0-development 2022-12-31 22:46:34 -04:00
Sasha Szpakowski c823dbca96 Update copyright year for 2023 2022-12-31 22:25:49 -04:00
slime 9c46b75138 ImageData:encode now supports saving exr image files.
Also add support for loading uint exr image files, and fix a memory leak in the exr loading code.

Resolves #1813.
2022-09-10 23:17:42 -03:00
Alex Szpakowski e61a664a8b ImageData: limited support for integer pixel formats.
For now this doesn't support conversions (get/set/mapPixel, etc). Just the ability for ImageData to contain integer pixel contents, for example via Canvas:newImageData.
2022-04-18 10:46:02 -03:00
Alex Szpakowski 7f3538d2ba Merge branch 'main' into 12.0-development 2022-01-05 21:10:27 -04:00
Alex Szpakowski 8e7fd10b6f Update copyright year for 2022 2021-12-31 18:33:40 -04:00
Alex Szpakowski 21f5ba86d3 Merge branch 'master' into 12.0-development 2021-04-07 20:33:44 -03:00
Alex Szpakowski f89aabb0bb Update copyright year for 2021 2021-04-04 16:14:45 -03:00
Alex Szpakowski 12c90b3dca Merge Image and Canvas GL backend classes into new common Texture class. 2020-02-07 20:29:21 -04:00
Alex Szpakowski 5f9b5a21d0 Merge default into minor
--HG--
branch : minor
2020-01-03 22:45:36 -04:00
Alex Szpakowski fc4847c69d Update copyright for the new year 2020-01-03 22:40:36 -04:00
Alex Szpakowski f3b52f66fe Update the internal naming convention for pixel formats.
--HG--
branch : minor
2019-12-23 23:38:04 -04:00
Alex Szpakowski a5ccfe4394 More clamping and rounding instead of truncating in ImageData:paste format conversion code, to match the behaviour of other color conversion code. 2019-09-21 22:20:16 -03:00
Alex Szpakowski 42a8107b07 Fix a compile error 2019-09-21 22:13:36 -03:00
Alex Szpakowski 2bf5a04937 Use a generic slow path for ImageData:paste between formats when we don't already have a faster path for it, instead of erroring. 2019-09-21 22:13:10 -03:00
Alex Szpakowski e11d43507e Reorganize ImageData:set/mapPixel code so less of it is in the Lua wrapper and more of it is in the ImageData class itself. 2019-09-21 21:48:03 -03:00
Alex Szpakowski c4fac73dc4 ImageData and Images now support the rg11b10f format. 2019-09-21 14:46:45 -03:00
Alex Szpakowski 94c66918a8 Add support for rgba4, rgb5a1, rgb565, and rgb10a2 ImageData formats. Also fix normalized 8 and 16 bit per component ImageData to round instead of floor (post-converted fixed point) fractional values in setPixel and mapPixel. 2019-09-21 11:02:40 -03:00
Alex Szpakowski 2a534893b1 Small ImageData code cleanup. 2019-06-04 20:33:44 -03:00
Alex Szpakowski 372a55c6ac ImageData supports more formats: r8, rg8, r16, rg16, r16f, rg16f, r32f, rg32f. Format conversion via ImageData:paste is not supported for those (yet). 2019-04-28 12:09:16 -03:00
Alex Szpakowski 0752f27bdf Update copyright year for 2019 2019-01-03 21:09:05 -04:00
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Bart van Strien 9e4374935d Show (short) list of possible enum values when an invalid value is encountered (resolves #1318)
All enum errors have (hopefully) been changed to a luax_enumerror, which has a
fixed error message. If additionally a list of valid options is passed, it
lists that in the error message. For every enum error with few options I've
implemented this using a getConstants call.

This solution has been designed specifically to reduce the number of template
instantiations (as I've been told that was a concern). All new template code
happens in places where there already was an instantiation of the relevant
StringMap. Of course there is still std::vector<std::string>...

--HG--
branch : minor
2017-10-02 17:11:53 +02:00
Alex Szpakowski a41f78dfe4 Simplified some compressed image parsing code.
--HG--
branch : minor
2017-08-30 22:25:26 -03:00
Alex Szpakowski 2dd6408d00 Images/[Compressed]ImageData can be created using any Data, instead of just files or FileData.
--HG--
branch : minor
2017-08-05 23:55:20 -03:00
Alex Szpakowski 84d5d8b636 Move decoder-agnostic love.image code out of the magpie backend folder.
--HG--
branch : minor
2017-08-01 23:22:24 -03:00
Alex Szpakowski 074107b01d ImageData:paste can copy between ImageData of different formats. Resolves issue #1249.
--HG--
branch : minor
2017-03-03 22:10:10 -04:00
Alex Szpakowski 73fd45558b Implement Array, Cubemap, and Volume texture types (issue #1111).
- Add love.graphics.newArrayImage, newCubeImage, and newVolumeImage.
- Add love.graphics.newCanvas(w, h, layers) and newCanvas(w, h, layers, settings). Add ‘type’ field to the settings table of newCanvas.

- Add new love.graphics.setCanvas variants: setCanvas(canvas, slice), and setCanvas(canvastable) where canvastable is in the format: {{canvas1, layer=2}, {canvas2, face=5}}

- Add Texture:getTextureType, getDepth, getLayerCount, getMipmapCount, and getFormat.

- Remove Image:getData and Image:refresh.
- Add Image:replacePixels(imagedata [, slice] [, mipmap]).

- Update Canvas:newImageData to accept a slice argument.

- Add love.image.newCubeFaces(imagedata).

--HG--
branch : minor
2017-02-20 14:58:13 -04:00
Alex Szpakowski abb72cb813 Happy new year! 🥂
--HG--
branch : minor
2017-01-02 01:28:29 -04:00
Alex Szpakowski f98b7ce1ed Fix ImageData:paste.
--HG--
branch : minor
2016-12-18 00:09:11 -04:00
Bart van Strien 7bd3581a52 Merge dynamiccore2 into minor
Instead of a global type enum and bitfield, all types now have their own
love::Type static member. This means they automatically assign their ids, build
their bitsets, etc. As a bonus, it simplifies wrapper code since most functions
already know which type they're pushing to or getting from lua, so they can
directly get the static member (if it's called 'type').

--HG--
branch : minor
2016-11-30 22:38:30 +01:00
Alex Szpakowski 0a3adc0839 Unify pixel format enums for ImageData, CompressedImageData, and Canvas into a single PixelFormat enum.
Replace love.graphics.getRawImageFormats and love.graphics.getCompressedImageFormats with love.graphics.getImageFormats.

--HG--
branch : minor
2016-11-27 22:53:23 -04:00
Bart van Strien d967a755e5 Make love::Type handle type names
TODO: Fix undefined behaviour in luax_register_type, you can't use a va_list after a reference type

--HG--
branch : dynamiccore2
2016-11-14 21:06:53 +01:00
Bart van Strien c761202486 Build type information on first use (load-time), instead of using a hardcoded list
--HG--
branch : dynamiccore2
2016-11-13 16:38:57 +01:00
Alex Szpakowski e71f95595c ImageData (and Images loaded from them) now support different data formats. Resolves issue #1048.
Currently exposed formats are rgba8 and rgba16 (normalized), and rgba16f and rgba32f (floating-point). Some systems, especially mobile ones, won't support every format when creating a love.graphics Image. Use love.graphics.getRawImageFormats to check for support.

love.image.newImageData now takes an optional format parameter as its third argument when creating an empty sized ImageData. It defaults to rgba8.

16-bit PNGs, .hdr images, and floating-point OpenEXR images can now be loaded via love.image.newImageData and love.graphics.newImage.

--HG--
branch : minor
2016-05-22 15:28:20 -03:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Bart van Strien 7e44034757 Add a MutexRef class to clean up Mutex handling code 2015-07-06 11:58:08 +02:00
Alex Szpakowski df1bd42dec Implemented efficient FFI versions of ImageData methods.
Note that ImageData:mapPixel (with its optional sub-rectangle parameters) is often many times faster than a loop of ImageData:setPixel and/or getPixel, for anything more than a few pixels.
2015-06-15 00:50:01 -03:00
Alex Szpakowski aac595525a Cleaned up some ImageData code. 2015-06-14 01:01:44 -03:00
Alex Szpakowski 457903a425 Renamed love.touch.getIDs to love.touch.getTouches. 2015-05-28 20:54:41 -03:00
Alex Szpakowski 5dbf589d47 Removed libjpeg-turbo as a dependency (closes issue #1031.) Removed jpeg support for ImageData:encode. stb_image now handles jpeg image loading. 2015-05-03 17:52:20 -03:00
Alex Szpakowski bf5f0b4175 bmp isn't a supported format for ImageData:encode.
--HG--
branch : minor
2015-03-01 23:38:34 -04:00
Alex Szpakowski c7b45b3505 Updated copyright for the new year 2014-12-31 19:32:43 -04:00
Alex Szpakowski 50916825d0 Data::getSize now uses size_t instead of int 2014-03-18 03:50:00 -03:00
Alex Szpakowski 3120a0e650 Goodbye 2013, hello 2014! 2014-01-03 17:28:58 -04:00
Alex Szpakowski b04a2fee87 Improved performance when using ImageData methods in multiple threads when ImageData:encode is called 2013-06-26 03:42:42 -03:00
Alex Szpakowski 6e3a7288dd Improved performance of ImageData:mapPixel (now up to 2x as fast as in 0.8.0!); love.graphics.newImage, Image:refresh, love.window.setIcon, and ImageRasterizers now prevent other threads from modifying the ImageData used in those functions until they're done accessing it 2013-06-25 05:28:20 -03:00
Alex Szpakowski 7ab3809165 Fixed Object:typeOf for love.physics objects new to 0.8.0, removed vestigial ColorMode code 2013-05-07 15:23:26 -03:00
Alex Szpakowski c215541d6c Merged mage-CompressedData into default 2013-04-09 23:44:00 -03:00