# SmartPictureBoxAdapter

## Overview

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.

## Configuration

```csharp
[Extends(typeof(PictureBox), allowMultiple: true)]
[WorksWith(typeof(OpenAIEndpointDallE))]
[WorksWith(typeof(LocalAIEndpointImageGen))]
```

## Properties

In addition to the properties inherited from the [SmartAdapter](/ai/components/adapters/smartadapter.md), the SmartPictureBoxAdapter exposes the following additional properties.

### ImageFormat

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.

### ImageSize

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/ai/components/adapters/smartpictureboxadapter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
