Page 1 of 1

Why does not update the color?

Posted: Fri Jul 02, 2004 4:22 pm
by bogho
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?

Posted: Fri Jul 02, 2004 4:29 pm
by bogho
When I used the GetPixel method returnd (0,0,0) and when try do draw the image with sADMDrawer, draws a black rectangle with the correct width and height

Posted: Sat Jul 03, 2004 3:59 pm
by bogho
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.

Posted: Sat Jul 03, 2004 4:00 pm
by bogho
The FOR is this:

for(long i=0;i<imageLen;i++)