SmartPictureBoxAdapter
Last updated
Last updated
This adapter serves as an intermediary between an image generation model and the PictureBox control. When a PictureBox is linked to this adapter, its Text property is utilized as the prompt for the image generation model. The adapter automatically sends the Text value to the model, which generates an image accordingly. The resulting image is then displayed within the PictureBox control, enabling dynamic image content based on developer-provided prompts.
If the AutoRun
property is set to true
, updating the Text
property of the PictureBox automatically triggers image generation—provided that the control has been associated with the adapter using this.hub.GetAI(this.pictureBox).Adapter = this.adapter
. In this mode, no additional calls are required to generate an image based on the Text property.
If AutoRun
is set to false
, image generation is not triggered automatically when the Text property changes. Instead, you must manually initiate the process by calling this.adapter.RunAsync(this.pictureBox)
. This approach gives you programmatic control over when the image generation occurs.
In addition to the properties inherited from the , the SmartPictureBoxAdapter exposes the following additional properties.
The ImageFormat property specifies the format of the image returned by the AI model. Typically, this value should be either "url"
or "base64"
, depending on how the model provides the generated image. The exact format supported may vary between different models.
Wisej.AI automatically detects whether the model’s response contains an image URL or a base64-encoded image. If a URL is returned, Wisej.AI will automatically download the image. If a base64 string is returned, Wisej.AI will decode and convert it to an image object. This ensures seamless integration regardless of the image format produced by the underlying AI model.
The ImageSize property specifies the dimensions of the generated image. Typically, valid values are "256x256"
, "512x512"
, or "1024x1024"
, although the exact set of supported sizes may vary depending on the underlying AI model. In general, generating smaller images is faster and requires fewer resources than generating larger ones. Always refer to the specific model's documentation to confirm which image sizes are supported.