Acki wrote:Dareltibus wrote:if i find a way to use this data in a faster way i will post it.
direct access using lock() and unlock() on the image makes it a lot faster...

already done
Dareltibus wrote:Code: Select all
IImage *dataImage = loadImage(L"pictures/wall.png") //R8G8B8A8
IImage *Image2= loadImage(L"pictures/wall2.png")
u8* pdata= dataImage->lock(); //pointer to image array
of course these are only silly samples on how to get things work.
here something nicer (i hope:) )
To make the code usefull, a lot more can be done. For example i didn't delete the pdata pointer. I think before Unlocking the image something must be done with it or the whole code will makes only a time waste
Ok here i separate the color components of our image into 4 arrays.. why?
well
normally height map is a grey scale image..
a grey color has the same 3 component so (1,1,1) ,(2,2,2),.... = 256 level of grey.
but if we use a R8G8B8A8 image why have only 1 height map with 256 level of height?
we can mix up to 4 different heightmap in only 1 image!(every color channel is a heightmap!) and then we can extract a single heightmap from one of the color channels dividing by 4 (or 3) the space required on the hard disk (for example, big and detailed maps) for storing heightmaps.
(actually irrlicht does not support greyscale image looking only at IImage..h, so maybe this will be usefull for someone)
Code: Select all
IImage *dataImage = loadImage(L"pictures/heightmap1_2_3_4.png") //R8G8B8A8
u8* pdata= dataImage->lock(); //pointer to image array
int x_dim=(int) dataImage->getDimension().Width;
int y_dim=(int) dataImage->getDimension().Height;
int limit = x_dim*y_dim;
u8* redvalues= new u8[limit];
u8* greenvalues= new u8[limit];
u8* bluevalues=new u8[limit];
u8* alphavalues= new u8[limit];
//do something with the image
for(int i=0;i<limit;i++){
redvalues[i]=pdata[4*i];
greenvalues[i]=pdata[4*i+1];
bluevalues[i]=pdata[4*i+2];
alphavalues[i]=pdata[4*i+3];
}
//now we have the new heightmaps we can release our image data
pdata->unlock();
pdata=0;
//... program runnin
//end of program
device->drop();
delete redvalues;
delete greenvalues;
delete bluevalues;
delete alphavalues;
return 0;