Window icon cannot be changed.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
larz
Prole
Posts: 9
Joined: Fri Jan 08, 2016 2:57 pm

Window icon cannot be changed.

Post by larz »

Code: Select all

local data =love.image.newImageData(16,16,"icon.png");
love.window.setIcon(icon);
"icon.png" is a 16x16px image.
When i run the the program i get this error:

"main.lua:1: The size of the raw byte string must match the ImageData's actual size in bytes."

Is there something wrong on the script?
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Window icon cannot be changed.

Post by pgimeno »

Check all the variants the documentation of newImageData. Note that none of the forms accepts a size followed by a filename. The closest is newImageData(filename), which doesn't need the size because it's encoded in the file itself.
Last edited by pgimeno on Fri Jan 08, 2016 7:21 pm, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Window icon cannot be changed.

Post by bartbes »

Yes, the three-argument version of newImageData accepts raw imagedata as the third argument.
In your case, you want the one-argument version, which accepts a filename.
larz
Prole
Posts: 9
Joined: Fri Jan 08, 2016 2:57 pm

Re: Window icon cannot be changed.

Post by larz »

But i need an ImageData for setting an Icon. Am i right?
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Window icon cannot be changed.

Post by pgimeno »

Yes.

In my first version of the post I asked if you were sure that you needed newImageData rather than newImage. Then I realized it was actually for an icon, not for drawing it yourself, so I deleted that part because for an icon, you need newImageData indeed.
larz
Prole
Posts: 9
Joined: Fri Jan 08, 2016 2:57 pm

Re: Window icon cannot be changed.

Post by larz »

Ok!
How could i do that? Is there a way to convert pixels to bytes and find the dimensions?
User avatar
slime
Solid Snayke
Posts: 3163
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Window icon cannot be changed.

Post by slime »

You can load an ImageData from a file like: local data = love.image.newImageData("icon.png")
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests