wrapp f-ja oko metode LoadImageInto
Code:
RASTER_API void LoadImageIntoRasterInstance(void *instance , unsigned char incomeImage[] , int width , int height)
{
MyPixel *pixels = new MyPixel[width * height];
unsigned int incomeImgCount = 0;
for (int i = 0 ; i < width * height ; i++)
{
pixels[i].R = incomeImage[incomeImgCount++];
pixels[i].G = incomeImage[incomeImgCount++];
pixels[i].B = incomeImage[incomeImgCount++];
}
CRaster *ras = (CRaster*)instance;
ras->LoadImageInto(pixels , width , height);
delete [] pixels;
}
RASTER_API void LoadImageIntoRasterInstance(void *instance , unsigned char incomeImage[] , int width , int height)
{
MyPixel *pixels = new MyPixel[width * height];
unsigned int incomeImgCount = 0;
for (int i = 0 ; i < width * height ; i++)
{
pixels[i].R = incomeImage[incomeImgCount++];
pixels[i].G = incomeImage[incomeImgCount++];
pixels[i].B = incomeImage[incomeImgCount++];
}
CRaster *ras = (CRaster*)instance;
ras->LoadImageInto(pixels , width , height);
delete [] pixels;
}
import f-je u c#
Code:
[DllImport("Raster.dll")]
public static extern void LoadImageIntoRasterInstance(IntPtr instance , [MarshalAs(UnmanagedType.LPArray)]byte [] incomeImage, int width , int height);
[DllImport("Raster.dll")]
public static extern void LoadImageIntoRasterInstance(IntPtr instance , [MarshalAs(UnmanagedType.LPArray)]byte [] incomeImage, int width , int height);
poziv f-je iz c#
Code:
Bitmap bmp = new Bitmap(path , false);
byte []pix = new byte[bmp.Width * bmp.Height * 3];
GetImageIntoArrayFast (bmp , pix);
LoadImageIntoRasterInstance(Raster , pix , bmp.Width , bmp.Height);
bmp.Dispose();
Bitmap bmp = new Bitmap(path , false);
byte []pix = new byte[bmp.Width * bmp.Height * 3];
GetImageIntoArrayFast (bmp , pix);
LoadImageIntoRasterInstance(Raster , pix , bmp.Width , bmp.Height);
bmp.Dispose();
E sad problem je u tome kada su rezolucije slika relativno male (3000 x 2000) tj kada niz ima malo elemenata sve radi normalno, medjutim kada niz koji prosledjujem kao parametar u funkciju ima 200 000 000 elemenata ispada mi NullPointerException (wtf sta kao radi do neke cifre :) )??? Da li neko moze da mi pomogne u cemu je problem i sta se tu desava. Da li nekako mogu da zakljucam niz u meoriji ili tako nesto i da li uopste dobro prosledjujem parametre. Problem je takodje sto ne mogu da debug-ujem jer imam aplikaciju koja ucitava dll (c# class library) koji pak opet ucitava dll (raster api). Help :(.
A da zaboravio sam da kazem kada c# deo koda prevedem u managed c++ sve radi ??????? bez obzira na duzinu niza
[Ovu poruku je menjao masetrt dana 05.01.2006. u 12:59 GMT+1]
His majesty Grand Duke of Shumadija and Western Pomoravlje