Why does not update the color?

Comments and discussions about 8bf plugins which can be use in various applications like Photoshop, Paint Shop Pro or Photo-Paint
Post Reply
bogho
Plugin Expert
Plugin Expert
Posts: 15
Joined: Mon Jun 28, 2004 9:13 am
Location: Romania
Contact:

Why does not update the color?

Post 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?

bogho
Plugin Expert
Plugin Expert
Posts: 15
Joined: Mon Jun 28, 2004 9:13 am
Location: Romania
Contact:

Post 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

bogho
Plugin Expert
Plugin Expert
Posts: 15
Joined: Mon Jun 28, 2004 9:13 am
Location: Romania
Contact:

Post 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.

bogho
Plugin Expert
Plugin Expert
Posts: 15
Joined: Mon Jun 28, 2004 9:13 am
Location: Romania
Contact:

Post by bogho »

The FOR is this:

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

Post Reply