Hello!
I tried to create a new ADMImageRef and fill it with some color. The code is:
ADMImageRef GetImage(int width, int height)
{
ASPoint pixelPoint;
ASRGBColor color;
ADMImageRef imageRef = sADMImage->CreateBitmap(width,height);
sADMImage->BeginBaseAddressAccess(imageRef);
for (long i=0; i<width;i++) for(long j=0;j<height;j++) {
pixelPoint.v=i;
pixelPoint.h=j;
color.red = 100;
color.blue = 100;
color.green = 100;
sADMImage->SetPixel(ImageRef , &pixelPoint, &color);
}
sADMImage->EndBaseAddressAccess(ImageRef);
return ImageRef;
}
But the problem is that it never displey corrected. Actually the pixel are not updated. (in the debug mode the pixels have (0,0,0) color and not (100, 100, 100) as it should be).
Does anyone know how to do it?
Why does not update the color?
I resolved the problem :
I was mixing access methods here. BeginBaseAddressAccess() an ASByte pointer, which I can use to walk thru the image and set values in the 0 to 255 range. Like:
ASByte* theImage = sADMImage->BeginBaseAddressAccess(imageRef);
for(long i=0;i<imageLen;i++)
{
theImage = 128;
}
sADMImage->EndBaseAddressAccess(imageRef);
On the other hand, SetPixel is expecting an ASRGBColor, which expects a short, so color values in the 0 to 255 range should be shifted left by 8:
color.red = ( 100 << 8 );
Either method works, but SetPixel() is much slower to call repeatedly, so it's not the best method for speed.
Bogdan.
I was mixing access methods here. BeginBaseAddressAccess() an ASByte pointer, which I can use to walk thru the image and set values in the 0 to 255 range. Like:
ASByte* theImage = sADMImage->BeginBaseAddressAccess(imageRef);
for(long i=0;i<imageLen;i++)
{
theImage = 128;
}
sADMImage->EndBaseAddressAccess(imageRef);
On the other hand, SetPixel is expecting an ASRGBColor, which expects a short, so color values in the 0 to 255 range should be shifted left by 8:
color.red = ( 100 << 8 );
Either method works, but SetPixel() is much slower to call repeatedly, so it's not the best method for speed.
Bogdan.