Понять что за ошибки в коде

maksgmn

Client
Регистрация
29.01.2016
Сообщения
204
Благодарностей
6
Баллы
18
Есть код, namespace со своими классами и методами, я хочу его подключить в свой проект, чтобы пользоваться этими самыми методами. Вот ссылка на проект товарища, у которого я беру код -> https://github.com/KSemenenko/ColorThief/tree/master/ColorThief.Desktop.v45
Подключаю следующим образом: весь namespace засовываю в общий код (правильно ли это?) ну и прописываю using-и в директивах using

upload_2018-8-2_13-44-39.png

Далее пытаюсь скомпилировать c# кубик и он мне выдает следующие ошибки, с которыми я не знаю как бороться (умеет ли c# zennoposter-а понимать params?)

upload_2018-8-2_13-46-33.png

Может кто пояснить смысл этих ошибок, почему они случаются?

Вот сам код, который засовываю в общий код:

Код:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.Text.RegularExpressions;
using ZennoLab.CommandCenter;
using ZennoLab.InterfacesLibrary;
using ZennoLab.InterfacesLibrary.ProjectModel;
using ZennoLab.InterfacesLibrary.ProjectModel.Collections;
using ZennoLab.InterfacesLibrary.ProjectModel.Enums;
using ZennoLab.Macros;
using Global.ZennoExtensions;
using ZennoLab.Emulation;
using System.IO;
using System.Drawing;
using System.Windows;
using System.Threading;
using System.Threading.Tasks;

namespace ColorThiefDotNet
{
    public partial class ColorThief
    {
        /// <summary>
        ///     Use the median cut algorithm to cluster similar colors and return the base color from the largest cluster.
        /// </summary>
        /// <param name="sourceImage">The source image.</param>
        /// <param name="quality">
        ///     1 is the highest quality settings. 10 is the default. There is
        ///     a trade-off between quality and speed. The bigger the number,
        ///     the faster a color will be returned but the greater the
        ///     likelihood that it will not be the visually most dominant color.
        /// </param>
        /// <param name="ignoreWhite">if set to <c>true</c> [ignore white].</param>
        /// <returns></returns>
        public QuantizedColor GetColor(Bitmap sourceImage, int quality = DefaultQuality, bool ignoreWhite = DefaultIgnoreWhite)
        {
            var palette = GetPalette(sourceImage, 3, quality, ignoreWhite);

            var dominantColor = new QuantizedColor(new Color
            {
                A = Convert.ToByte(palette.Average(a => a.Color.A)),
                R = Convert.ToByte(palette.Average(a => a.Color.R)),
                G = Convert.ToByte(palette.Average(a => a.Color.G)),
                B = Convert.ToByte(palette.Average(a => a.Color.B))
            }, Convert.ToInt32(palette.Average(a => a.Population)));

            return dominantColor;
        }

        /// <summary>
        ///     Use the median cut algorithm to cluster similar colors.
        /// </summary>
        /// <param name="sourceImage">The source image.</param>
        /// <param name="colorCount">The color count.</param>
        /// <param name="quality">
        ///     1 is the highest quality settings. 10 is the default. There is
        ///     a trade-off between quality and speed. The bigger the number,
        ///     the faster a color will be returned but the greater the
        ///     likelihood that it will not be the visually most dominant color.
        /// </param>
        /// <param name="ignoreWhite">if set to <c>true</c> [ignore white].</param>
        /// <returns></returns>
        /// <code>true</code>
        public List<QuantizedColor> GetPalette(Bitmap sourceImage, int colorCount = DefaultColorCount, int quality = DefaultQuality, bool ignoreWhite = DefaultIgnoreWhite)
        {
            var pixelArray = GetPixelsFast(sourceImage, quality, ignoreWhite);
            var cmap = GetColorMap(pixelArray, colorCount);
            if(cmap != null)
            {
                var colors = cmap.GeneratePalette();
                return colors;
            }
            return new List<QuantizedColor>();
        }

        private byte[][] GetPixelsFast(Bitmap sourceImage, int quality, bool ignoreWhite)
        {
            if(quality < 1)
            {
                quality = DefaultQuality;
            }

            var pixels = GetIntFromPixel(sourceImage);
            var pixelCount = sourceImage.Width*sourceImage.Height;

            return ConvertPixels(pixels, pixelCount, quality, ignoreWhite);
        }

        private byte[] GetIntFromPixel(Bitmap bmp)
        {
            var pixelList = new byte[bmp.Width * bmp.Height * 4];
            int count = 0;

            for (var x = 0; x < bmp.Width; x++)
            {
                for (var y = 0; y < bmp.Height; y++)
                {
                    var clr = bmp.GetPixel(x, y);

                    pixelList[count] = clr.B;
                    count++;

                    pixelList[count] = clr.G;
                    count++;

                    pixelList[count] = clr.R;
                    count++;

                    pixelList[count] = clr.A;
                    count++;
                }
            }

            return pixelList;
        }
    }
}
 

SergSh

Client
Регистрация
10.05.2017
Сообщения
541
Благодарностей
395
Баллы
63

Alex733

Client
Регистрация
27.11.2017
Сообщения
329
Благодарностей
240
Баллы
43
Как в с# кубике вызываешь методы подгруженного namespace?
 

maksgmn

Client
Регистрация
29.01.2016
Сообщения
204
Благодарностей
6
Баллы
18

Alex733

Client
Регистрация
27.11.2017
Сообщения
329
Благодарностей
240
Баллы
43
Имена, на которые ругается ПМ находятся в папке ColorThieft.Shared. Их нужно правильно скопировать (подключить) в общий код.
 

maksgmn

Client
Регистрация
29.01.2016
Сообщения
204
Благодарностей
6
Баллы
18

Alex733

Client
Регистрация
27.11.2017
Сообщения
329
Благодарностей
240
Баллы
43
https://github.com/KSemenenko/ColorThief/ - Корневая папка проекта. Внизу есть указанная папка (ColorThieft.Shared). Простым копипастом работать не будет. Это проект VisualStudio. Просто нужно скопировать нужные строчки в OwnCode по правилам C#.
 
  • Спасибо
Реакции: maksgmn

maksgmn

Client
Регистрация
29.01.2016
Сообщения
204
Благодарностей
6
Баллы
18
https://github.com/KSemenenko/ColorThief/ - Корневая папка проекта. Внизу есть указанная папка (ColorThieft.Shared). Простым копипастом работать не будет. Это проект VisualStudio. Просто нужно скопировать нужные строчки в OwnCode по правилам C#.
Слушайте, а если я пока путаюсь в c#, можно как-то в .dll скомпилировать этот проект и подключить как библиотеку? Если да, то как это можно сделать, ткните, пожалуйста меня в ссылку или так напишите
 

Alex733

Client
Регистрация
27.11.2017
Сообщения
329
Благодарностей
240
Баллы
43
Может и можно, но мне проще было скопировать из этой папки нужный код в нужное место. Я попробовал сделать. Нужно просто скопировать код внутрь namespace ColorThief. Например:
Код:
namespace ColorThief
{
    public class QuantizedColor
    {
        public QuantizedColor(Color color, int population)
        {
            Color = color;
            Population = population;
            IsDark = CalculateYiqLuma(color) < 128;
        }

        public Color Color { get; private set; }
        public int Population { get; private set; }
        public bool IsDark { get; private set; }

        public int CalculateYiqLuma(Color color)
        {
            return Convert.ToInt32(Math.Round((299 * color.R + 587 * color.G + 114 * color.B) / 1000f));
        }
    }
И так повторять пока не прекраться ошибки.
 
  • Спасибо
Реакции: maksgmn

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)