Image:getImageData() and Source:getSoundData()

Issue #364 wontfix
created an issue

Maybe what I'm asking here is totally not possible. I have not looked at the source code of Image nor Source, so I don't know whether there are technical reasons for which these two methods simply not possible to implement.

I'm writing this in the hopes that they are implementable but someone has just overlooked the possibility of providing them or something.

If not doable, can you provide a reason? Thanks!

Comments (5)

  1. Bill Meltsner

    Source:getSoundData() would not, at present, be possible if the Source was streaming - there's no provision for that.

    Image:getImageData() is technically possible.

    In both cases, however, the name is misleading - it would return a copy of the Image/SoundData for the object; modifying these would do nothing unless you recreated an Image/Source from the modified data. And in that case, I can't see any real benefit to providing Image:getImageData over simply calling love.image.newImageData on the image file, and using that instead.

    I'll leave this open for now in case you or someone else can come up with a compelling justification for their implementation, but at this point I've mentally marked this "wontfix" (there needs to be a better equivalent of that for proposals).

  2. kikito reporter

    I have been thinking about this and I think I got a possible scenario where this would be useful.

    Say I have a lib that somehow produces images - the means are not important: it could just download them from the web, calculate them via a procedural algorithm, or whatever. What is important is that the product is an Image object - not an ImageData.

    If I wanted to work with the images produced by that lib (like applying a filter, or replacing a color by an alpha, etc), that would be possible, but not convenient: I would have to create an empty imageData with the same size of the image, then "draw" the image on top of it, and then apply the changes on the ImageData created that way. It would be convenient to be able to access the Image's imageData directly, even if it was just a copy.

    The same goes for sources and soundData. Is it really not possible to get the soundData from a source? If that's the case, then I guess the best option is telling people developing libraries that produce images/sound that they *must* provide imageDatas and soundDatas in addition to images and sources, and simply closing up this issue.

    On the other hand, if there is a slight possibility of getting the soundData out of a source, then I would leave this issue open.

    Thanks and regards!

  3. Log in to comment