Skip to content
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

How to access palette of 8-bit png? #712

Closed
TomQv opened this issue Feb 15, 2017 · 1 comment
Closed

How to access palette of 8-bit png? #712

TomQv opened this issue Feb 15, 2017 · 1 comment

Comments

@TomQv
Copy link

TomQv commented Feb 15, 2017

var bmp8=new Bitmap(my8bitpngfile);
using (var data=bmp8.Lock())
{
    var pixel=data.GetPixel(0,0);    // throws NotSupportedException!!!
}

Problem seems to be, that in Eto.Shared.Drawing.BaseBitmapData.GetPixel(int x, int y):
var bmp = Image as IndexedBitmap;
returns null.

@cwensley
Copy link
Member

You need to use IndexedBitmap instead. E.g.

var myBmp = new IndexedBitmap(my8bitpngfile);
var palette = myBmp.Palette; // in case you need it
using (var data=bmp8.Lock())
{
    var pixel=data.GetPixel(0,0);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants