This is a mirror of official site:

Calling IPP Functions from C# Code

| Wednesday, August 22, 2012
Intel Integrated Performance Primitives, also known as IPP, is a library of highly optimized math software functions for digital media and data-processing applications. The functions use multiple threads and the most appropriate SIMD instructions to achieve the best performance according to instruction set architecture available in the underlying hardware. You can call IPP functions from your C# code through Platform Invokes, also known as P/Invokes.

Intel IPP 8.0 or higher includes all the necessary code that allows you to easily call IPP functions in any C# project. However, the necessary code is included in an almost hidden language-related samples zip file. Thus, you have to decompress the zip file in a new folder to find the necessary C# files that will allow you to call the different IPP functions. These samples are usually compressed into a file called "" and located within the IPP subfolder of the Intel product that includes IPP. If you have problems locating this file, you can just search for it in the Intel folder found in Program Files (x86). For example, Intel Parallel Composer 2011 includes the IPP samples in Program Files (x86)\Intel\Parallel Studio 2011\Composer\Samples\en_US\IPP. See Figure 1. In a 32-bit Window version, instead of the Program Files (x86) folder, it will be just the Program Files folder.

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Interop;
using ipp;
namespace IppCSharpExample
    public partial class MainWindow : Window
        public MainWindow()
        private BitmapData GetBitmapData(Bitmap bitmap, ImageLockMode lockMode)
            return bitmap.LockBits(
                new System.Drawing.Rectangle(0, 0, 
                    bitmap.Width, bitmap.Height),
        unsafe private Bitmap ApplyFilterSobelHoriz(string fileName)
            var originalImage = new Bitmap(fileName);
            var sourceBitmapData = GetBitmapData(originalImage, ImageLockMode.ReadOnly);
            var destinationImage = new Bitmap(originalImage.Width, originalImage.Height);
            var destinationBitmapData = GetBitmapData(destinationImage, ImageLockMode.ReadWrite);
            IppiSize roi = new IppiSize(originalImage.Width - 3, originalImage.Height - 3);
            const int ksize = 5;
            const int half = ksize / 2;
            byte* pSrc = (byte*)sourceBitmapData.Scan0 + (sourceBitmapData.Stride + 3) * half;
            byte* pDst = (byte*)destinationBitmapData.Scan0 + (destinationBitmapData.Stride + 3) * half;
            IppStatus status = ipp.ip.ippiFilterSobelHoriz_8u_C3R(
                pSrc, sourceBitmapData.Stride,
                pDst, destinationBitmapData.Stride,

Read more: Dr Dobbs
QR: Inline image 1

Posted via email from Jasper-net