70002220 Image with null image definition is not scaled properly

Article 70002220
Type HowTo
Product Engine
Version 8
Date Added 5/26/2022 12:00:00 AM
Fixed 10 (5/26/2022 12:00:00 AM)
Submitted by Soon Hui Ngu

Summary

Image is not scaled properly, in the attached drawing the "empty" image (image definition is null) is not scaled in X axis properly

Solution

That is because these kind of images (images with null imagedefs) as their “pixel size width/height ratio etc” is missing cannot be scaled like ordinary vdImages with not null (that is with valid) image definitions.
So alter your code to :

// scale all objects of the vdDocument.Model
foreach (vdFigure vdFigure in doc.Model.Entities)
{
    vdImage img = vdFigure as vdImage;
    if (img != null)
    {
        if (img.ImageDefinition == null) // image with null Image def.
        {
            bool oldval = img.KeepAspect;
            img.KeepAspect = false;
            img.Transformby(matrix);
            img.KeepAspect = oldval;
        }
        else // image withcorrect imagedefinition
        {
            vdFigure.Transformby(matrix);
        }
    }
    else // not image
    {
        vdFigure.Transformby(matrix);
    }
}
Note: If these image definitions cannot be recovered and always are going to be null then it might be better to delete them (img.Deleted=true) so they are removed from the document by VDF.

Send comments on this topic.