New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICOFamily is no longer broken - writing ICO files works. #3
Conversation
Functional in simple tests, but needs more testing for edge cases; it makes heavy assumptions about the internal format of the NSBitmapImageReps and has no error checking.
ICOFamily is no longer broken - writing ICO files works. - Thanks metheweis
Wow, thanks I just merged it. I would have worked on this class more but the project I was using it in is no longer in development. |
Can you tell me the function of the andBuf? |
Hi Alex, Sure, it is basically a 1-bit mask... It makes more sense if you think about the 1-bit and 8-bit icons. It is confusing that it is still required for 32-bit formats since they have their own 8-bit alpha as well... I have tried making 32-bit ico bitmaps without the and mask but many applications have trouble parsing them. By the way, what were you planning to make out of ICOFamily? Please let me know if you need any more info. Thanks, -Mathew Eis On 17 Dec 2011, at 09:22, Alex Zielenski wrote:
|
I should add that I took advantage of that fact and hacked the andBuf... really the data should be generated based on the 8-bit alpha channel, but since most apps will ignore the andBuf it didn't matter. I just wanted to get it working to see if ICOFamily would work for my application and thought I might as well contribute that source back up. -Mathew Eis On 17 Dec 2011, at 09:47, Mathew Eis wrote:
|
Ok that makes sense. Also, why does the and mask require double height? And I was planning on making ICOFamily an ICO counterpart to IconFamily. |
The double height seems to be a (painfully undocumented) way to indicate that the image data contains two images; the actual data, then the mask... I can't really be sure. It is not mentioned on MSDN at all, but every ICO reader/writer I have seen uses it, and if it is left out some apps have trouble reading the data. I found that for my app I need an ICO writer that uses CGImageRef natively, so I am writing my own from scratch. IconFamily uses NSBitmapImageRep which stores data in premultiplied alpha format - convenient for use with NSImage, but data is lost over time. If you need some more guidance on reading/writing ICO directly, you should look at these three programs: Hope this helps, -Mathew Eis On 17 Dec 2011, at 10:06, Alex Zielenski wrote:
|
NSBitmapImageRep has a -CGImage method |
NSBitmapImageRep does not support unpremultiplied alpha format, so data will be lost when converting from CGImageRef (unpremultiplied alpha) to NSBitmapImageRep (premultiplied alpha) On 17 Dec 2011, at 11:21, Alex Zielenski wrote:
|
Functional in simple tests, but needs more testing for edge cases; it
makes heavy assumptions about the internal format of the
NSBitmapImageReps and has no error checking. At least it works now.