ResizeGetBufSize.
I am using Visual Basic 2008 and mycode is:
Dim buffsize As Integer
nChannel = 1
myStatus = ip.ippiResizeGetBufSize(srcRect, dstRect, nChannel, Interpolation.IPPI_INTER_NN, buffsize)
This produces the error:
ippStsNullPtrErr {-8}
I should state that my objective is to create an app that reads a JPG, resizes it, compresses it, and then saves the new JPG as a different file. Speed is of the utmost importance in this app.
Terry
myStatus = ip.ippiResize_8u_C3R(bmpsrcdata.Scan0, srcROI, bmpsrcdata.Stride, srcRect, bmpdstdata.Scan0, bmpdstdata.Stride, dstROI, xFactor, yFactor, Interpolation.IPPI_INTER_NN)
This works, however, when I save the destination image, the imageshows my reduced image on top of my full image. Also, the file size is about 3.5 MB. The original image size is only 223 KB so no compression (quality) is applied. Also, the code shown below produces an error:
Dim stt As IppStatus = ip.ippiQualityIndex_8u32f_C3R(bmpsrcdata.Scan0, bmpsrcdata.Stride, bmpdstdata.Scan0, bmpdstdata.Stride, dstROI, 75)
Here is my VB.Net code:
Dim xFactor As Double
Dim yFactor As Double
Dim nChannel As Integer
Dim buffsize As Integer
Dim myStatus As IppStatus = IppStatus.ippStsNoErr
Dim bmpsrcdata As BitmapData = getBmpData(bmpsrc)
bmpdst = New Bitmap(bmpsrc)
Dim bmpdstdata As BitmapData = getBmpData(bmpdst)
Dim srcROI As IppiSize = New IppiSize(bmpsrc.Width, bmpsrc.Height)
Dim dstROI As IppiSize = New IppiSize(bmpdst.Width, bmpdst.Height)
'*******************************
' Set Image Scaling Factors.
'*******************************
If doHalf = True Then
xFactor = 0.5
yFactor = 0.5
Else
xFactor = dstWidth / dstROI.width
yFactor = dstHeight / dstROI.height
End If
Dim srcRect As IppiRect = New IppiRect(0, 0, bmpsrcdata.Width, bmpsrcdata.Height)
Dim dstRect As IppiRect = New IppiRect(0, 0, bmpdstdata.Width, bmpdstdata.Height)
nChannel = 1
buffsize = 0
GoTo here
myStatus = IppStatus.ippStsNoErr
m_start = ipp.core.ippGetCpuClocks()
myStatus = ip.ippiResize_8u_C3R(bmpsrcdata.Scan0, srcROI, bmpsrcdata.Stride, srcRect, bmpdstdata.Scan0, bmpdstdata.Stride, dstROI, xFactor, yFactor, Interpolation.IPPI_INTER_NN)
m_stop = ipp.core.ippGetCpuClocks()
If (myStatus <> IppStatus.ippStsNoErr) Then
msg("Resize", myStatus)
End If
bmpsrc.UnlockBits(bmpsrcdata)
bmpdst.UnlockBits(bmpdstdata)
'***************************************
' Adjust JPG Quality (Compression).
'***************************************
bmpsrcdata = getBmpData(bmpsrc)
bmpdstdata = getBmpData(bmpdst)
dstROI = New IppiSize(bmpdst.Width, bmpdst.Height)
Try
Dim stt As IppStatus = ip.ippiQualityIndex_8u32f_C3R(bmpsrcdata.Scan0, bmpsrcdata.Stride, bmpdstdata.Scan0, bmpdstdata.Stride, dstROI, 75)
Catch ex As Exception
Dim a As Integer
End Try
bmpsrc.UnlockBits(bmpsrcdata)
bmpdst.UnlockBits(bmpdstdata)
bmpsrc.Save("C:\Test_SRC.jpg")
bmpdst.Save("C:\Test_DST.jpg")
Invalidate()
Any help would be greatly appreciated. I think I am very close but just have difficulties finishing up.
Terry
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for(j = 0; j < encoders.Length; ++j)
{
if(encoders.MimeType == mimeType)
return encoders;
}
return null;
}
private void SaveJPGWithCompressionSetting( Image image, string szFileName, long lCompression )
{
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter( Encoder.Quality, lCompression );
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
image.Save( szFileName, ici, eps );
}
That is C#, but the 3rd result was the VB translation : link
If you want to save JPEG images with IPP you'll have to go through the samples.
Regards,
Matthieu
For more complete information about compiler optimizations, see our Optimization Notice.