Пример #1
0
        float4[,]       LoadImage()
        {
            if (openFileDialog.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
            {
                return(null);
            }

            try {
                using (ImageFile I = new ImageFile(new System.IO.FileInfo(openFileDialog.FileName))) {
                    float4[,]       result = new float4[I.Width, I.Height];
                    I.ReadPixels((uint _X, uint _Y, ref float4 _color) => { result[_X, _Y] = _color; });
                    if (I.Width != MASK_SIZE || I.Height != MASK_SIZE)
                    {
                        // Resize
                        float4[,]       wrongResult = result;
                        result = new float4[MASK_SIZE, MASK_SIZE];
                        for (uint Y = 0; Y < MASK_SIZE; Y++)
                        {
                            for (uint X = 0; X < MASK_SIZE; X++)
                            {
                                ImageFile.BilerpClamp(wrongResult, (float)X * I.Width / MASK_SIZE, (float)Y * I.Height / MASK_SIZE, ref result[X, Y]);
                            }
                        }
                    }

                    return(result);
                }
            } catch (Exception _e) {
                MessageBox.Show(this, "An error occurred:\r\n" + _e.Message, "Painter Test", MessageBoxButtons.OK);
            }

            return(null);
        }