KSemenenko / ColorThief

Color Thief for .NET
MIT License
163 stars 28 forks source link

Exception = {"(expectedDataLength = 9216000) != (pixels.length = 18432000)"} #4

Closed niels9001 closed 7 years ago

niels9001 commented 7 years ago

I'm getting the above error when using the source package hosted here, or NuGet package 1.0.0. This is for every image.

FileOpenPicker fileOpenPicker = new FileOpenPicker(); fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; fileOpenPicker.FileTypeFilter.Add(".jpg"); fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;

        var inputFile = await fileOpenPicker.PickSingleFileAsync();

        if (inputFile == null)
        {
            // The user cancelled the picking operation
            return;
        }

        SoftwareBitmap softwareBitmap;

        using (IRandomAccessStream stream = await inputFile.OpenAsync(FileAccessMode.Read))
        {
            // Create the decoder from the stream
            BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);

            // Get the SoftwareBitmap representation of the file
            softwareBitmap = await decoder.GetSoftwareBitmapAsync();

            var colorThief = new ColorThief.ColorThief();
            List<QuantizedColor> colors = await colorThief.GetPalette(decoder, 8);

}

KSemenenko commented 7 years ago

Hello! Thank you for your interest, but I do not think that the library is working steadily for UWP, now there is a problem with the conversion of images into an array of bytes. perhaps you could help the project?

KSemenenko commented 7 years ago

@Niels9001 I think that'll fix it soon

KSemenenko commented 7 years ago

@niels9001 Hi, please check new version from NuGet

niels9001 commented 7 years ago

@KSemenenko If I load the NuGet I'm still getting: https://github.com/KSemenenko/ColorThief/issues/3

Have you changed the code on this GitHub as well? I'll just load in that code to see if it works!

KSemenenko commented 7 years ago

Now should work :) Issue #3 still in progress

niels9001 commented 7 years ago

It seems to work now :)!

Found the solution for Issue #3 as well: the default NuGet package (Microsoft.NETCore.UniversalWindowsPlatform) had to be upgraded to the latest version (5.2.2) as well!

Thanks!!!