private bool[,] ProcessImage(Func <bool[, ], bool[, ]> imageDataProcessor, FirmwareImageMetadata imageMetadata, bool rebuildCache = false)
        {
            var processedData      = imageDataProcessor(ImagePixelGrid.Data);
            var processedImageSize = processedData.GetSize();
            var imageSizeChanged   = imageMetadata.Width != processedImageSize.Width || imageMetadata.Height != processedImageSize.Height;

            imageMetadata.Width  = (byte)processedImageSize.Width;
            imageMetadata.Height = (byte)processedImageSize.Height;

            m_firmware.WriteImage(processedData, imageMetadata);

            if (imageSizeChanged || rebuildCache)
            {
                ImageCacheManager.RebuildCache(m_firmware);
                ImageListBox.Invalidate();
            }
            else
            {
                var cachedImage = BitmapProcessor.CreateBitmapFromRaw(processedData);
                ImageCacheManager.SetGlyphImage(imageMetadata.Index, imageMetadata.BlockType, cachedImage);
                ImageCacheManager.RebuildStringImageCache(m_firmware, imageMetadata.BlockType);
                var updateCache = new Action(() =>
                {
                    ImageListBox.Invoke(new Action(() =>
                    {
                        var itemRect = ImageListBox.GetItemRectangle(imageMetadata.Index - 1);
                        ImageListBox.Invalidate(itemRect);
                    }));
                });
                updateCache.BeginInvoke(null, null);
            }

            IsDirty = true;
            return(processedData);
        }