docs: protected Dimension getDimensions(Image pImage, int pWidth, int pHeight,
                                        int pUnits, boolean pUniformScale) {
  
          // If uniform, make sure width and height are scaled the same ammount
          // (use ONLY height or ONLY width).
          //
          // Algoritm:
          // if uniform
          //    if newHeight not set
          //       find ratio newWidth / oldWidth
          //       oldHeight *= ratio
          //    else if newWidth not set
          //       find ratio newWidth / oldWidth
          //       oldHeight *= ratio
          //    else
          //       find both ratios and use the smallest one
          //       (this will be the largest version of the image that fits
          //        inside the rectangle given)
          //       (if PERCENT, just use smallest percentage).
          //
          // If units is percent, we only need old height and width
  
          int oldWidth = ImageUtil.getWidth(pImage);
          int oldHeight = ImageUtil.getHeight(pImage);
          float ratio;
  
          if (pUnits == UNITS_PERCENT) {
              if (pWidth >= 0 && pHeight >= 0) {
                  // Non-uniform
                  pWidth = (int) ((float) oldWidth * (float) pWidth / 100f);
                  pHeight = (int) ((float) oldHeight * (float) pHeight / 100f);
              }
              else if (pWidth >= 0) {
                  // Find ratio from pWidth
                  ratio = (float) pWidth / 100f;
                  pWidth = (int) ((float) oldWidth * ratio);
                  pHeight = (int) ((float) oldHeight * ratio);
              }
              else if (pHeight >= 0) {
                  // Find ratio from pHeight
                  ratio = (float) pHeight / 100f;
                  pWidth = (int) ((float) oldWidth * ratio);
                  pHeight = (int) ((float) oldHeight * ratio);
              }
              // Else: No scale
          }
          else if (pUnits == UNITS_PIXELS) {
              if (pUniformScale) {
                  if (pWidth >= 0 && pHeight >= 0) {
                      // Compute both ratios
                      ratio = (float) pWidth / (float) oldWidth;
                      float heightRatio = (float) pHeight / (float) oldHeight;
  
                      // Find the largest ratio, and use that for both
                      if (heightRatio < ratio) {
                          ratio = heightRatio;
                          pWidth = (int) ((float) oldWidth * ratio);
                      }
                      else {
                          pHeight = (int) ((float) oldHeight * ratio);
                      }
  
                  }
                  else if (pWidth >= 0) {
                      // Find ratio from pWidth
                      ratio = (float) pWidth / (float) oldWidth;
                      pHeight = (int) ((float) oldHeight * ratio);
                  }
                  else if (pHeight >= 0) {
                      // Find ratio from pHeight
                      ratio = (float) pHeight / (float) oldHeight;
                      pWidth = (int) ((float) oldWidth * ratio);
                  }
                  // Else: No scale
              }
          }
  
          // Default is no scale, just work as a proxy
          if (pWidth < 0) {
              pWidth = oldWidth;
          }
          if (pHeight < 0) {
              pHeight = oldHeight;
          }
  
          // Create new Dimension object and return
          return new Dimension(pWidth, pHeight);
      }