if(newImage->mask_bm && !PiGetPixelFromData((uint8_t*)old_mask_ptr,Pg_BITMAP_TRANSPARENT,src.x,&value))
if(newImage->mask_bm && !PiGetPixelFromData((const uint8_t *)old_mask_ptr,Pg_BITMAP_TRANSPARENT,src.x,&value))
PhImage_t *MyPiResizeImage(PhImage_t *image,PhRect_t const *bounds,short w,short h,int flags){	PhRect_t oldRect,newRect,srcRect;	PhPoint_t dst,src;	PhImage_t *newImage;	unsigned long value,xScale,yScale,xScaleInv = 0,yScaleInv = 0;	char *ptr,*new_mask_ptr;	char const *old_mask_ptr;	struct	{		unsigned short x,y;	} next;	if(bounds)		srcRect = *bounds;	else	{		srcRect.ul.x = srcRect.ul.y = 0;		srcRect.lr.x = image->size.w - 1;		srcRect.lr.y = image->size.h - 1;	}		oldRect.ul.x = oldRect.ul.y = 0;	oldRect.lr.x = w - 1;	oldRect.lr.y = h - 1;				if(!(newImage = PiInitImage(image,(PhRect_t const*)(&oldRect),&newRect,0,flags | Pi_USE_COLORS,image->colors)))		return(NULL);	if(image->mask_bm)	{		newImage->mask_bpl = (((newImage->size.w + 7) >> 3) + 3) & ~3;		if((newImage->mask_bm = (char *)malloc(newImage->size.h * newImage->mask_bpl)) != NULL)			memset(newImage->mask_bm,0xff,newImage->size.h * newImage->mask_bpl);		else			newImage->mask_bpl = 0;	}		if((xScale = GR_FPDIV(newImage->size.w << 16,(srcRect.lr.x - srcRect.ul.x + 1) << 16)) <= 0x10000)		xScaleInv = GR_FPDIV((srcRect.lr.x - srcRect.ul.x + 1) << 16,newImage->size.w << 16);	if((yScale = GR_FPDIV(newImage->size.h << 16,(srcRect.lr.y - srcRect.ul.y + 1) << 16)) <= 0x10000)		yScaleInv = GR_FPDIV((srcRect.lr.y - srcRect.ul.y + 1) << 16,newImage->size.h << 16);	for(dst.y = 0,next.y = srcRect.ul.y << 16,src.y = srcRect.ul.y,ptr = newImage->image,old_mask_ptr = image->mask_bm,new_mask_ptr = newImage->mask_bm;	  dst.y < newImage->size.h;	  dst.y++,ptr += newImage->bpl,new_mask_ptr += newImage->mask_bpl)	{		if(yScaleInv)		{			src.y = next.y >> 16;			next.y += yScaleInv;		}		else		{			if(dst.y < (next.y >> 16) || src.y > srcRect.lr.y)			{				memcpy(ptr,ptr - newImage->bpl,newImage->bpl);				if(newImage->mask_bm)					memcpy(new_mask_ptr,new_mask_ptr - newImage->mask_bpl,newImage->mask_bpl);				continue;			}			else				next.y += yScale;		}		if(newImage->mask_bm)			old_mask_ptr = image->mask_bm + (src.y * image->mask_bpl);		if(xScaleInv)		{			for(dst.x = 0,next.x = srcRect.ul.x << 16,src.x = srcRect.ul.x;			  dst.x < newImage->size.w;dst.x++,next.x += xScaleInv)			{				src.x = next.x >> 16;				PiGetPixel(image,src.x,src.y,&value);				PiSetPixel(newImage,dst.x,dst.y,value);								if(newImage->mask_bm && !PiGetPixelFromData((uint8_t*)old_mask_ptr,Pg_BITMAP_TRANSPARENT,src.x,&value))				{					if(!value)						PiSetPixelInData((uint8_t*)new_mask_ptr,Pg_BITMAP_TRANSPARENT,dst.x,0);				}			}		}		else		{			unsigned long color = 0;						for(dst.x = 0,next.x = srcRect.ul.x << 16,src.x = srcRect.ul.x;			  dst.x < newImage->size.w;dst.x++)			{				if(dst.x == (next.x >> 16) && src.y <= srcRect.lr.y)				{					if(!PiGetPixel((const PhImage_t *)image,src.x,src.y,&color) && (!newImage->mask_bm || PiGetPixelFromData((const uint8_t *)old_mask_ptr,Pg_BITMAP_TRANSPARENT,src.x,&value)))						value = 1;					next.x += xScale;										src.x++;				}									PiSetPixel(newImage,dst.x,dst.y,color);								if(!value)					PiSetPixelInData((uint8_t*)new_mask_ptr,Pg_BITMAP_TRANSPARENT,dst.x,0);			}		}				if(!yScaleInv)			src.y++;	}	/* Calculate CRC tags for new image */	if(!(flags & Pi_SUPPRESS_CRC))		newImage->image_tag = PtCRC(newImage->image,newImage->bpl * newImage->size.h);	if(flags & Pi_FREE)	{		image->flags |= Ph_RELEASE_IMAGE | Ph_RELEASE_PALETTE | Ph_RELEASE_TRANSPARENCY_MASK | Ph_RELEASE_GHOST_BITMAP;		PhReleaseImage(image);	}	return(newImage);	}