> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/smartadapter/wisej.ai.adapters.smartpictureboxadapter.md).

# SmartPictureBoxAdapter

Namespace: **Wisej.AI.Adapters**

Assembly: **Wisej.AI** (3.5.0.0)

* [SmartAdapter](/ai/components/api/smartadapter.md)
  * [SmartPictureBoxAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartpictureboxadapter.md)

Represents an adapter for a PictureBox that generates images based on a description using the OpenAI DALL-E endpoint.

{% tabs %}
{% tab title="C#" %}

```csharp
public class SmartPictureBoxAdapter : SmartAdapter
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class SmartPictureBoxAdapter
    Inherits SmartAdapter
```

{% endtab %}
{% endtabs %}

This adapter extends the functionality of a PictureBox by allowing it to generate images from text descriptions. It works with the OpenAI DALL-E endpoint and supports different image formats and sizes.

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) SmartPictureBoxAdapter()

Initializes a new instance of [SmartPictureBoxAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartpictureboxadapter.md).

## Properties

### ![](/files/ptrKjmmRoQB76pvrIqh0) ImageFormat

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the format in which the generated images are returned. Must be one of "url" or "b64\_json". (Default: `"url"`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) ImageSize

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the size of the generated images. Must be one of "256x256", "512x512", or "1024x1024". Smaller images are faster. (Default: `"1024x1024"`)

For DALL-E-2, image sizes must be one of "256x256", "512x512", or "1024x1024". When using DALL-E-3, images can have a size of 1024x1024, 1024x1792, or 1792x1024 pixels.

## Methods

### ![](/files/KL0Ik37djZRr8a07Wopd) OnControlCreated(control)

Handles the event when the control is created.

| Parameter   | Type                                                      | Description                   |
| ----------- | --------------------------------------------------------- | ----------------------------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) | The control that was created. |

### ![](/files/KL0Ik37djZRr8a07Wopd) OnControlDisposed(control)

Handles the event when the control is disposed.

| Parameter   | Type                                                      | Description                    |
| ----------- | --------------------------------------------------------- | ------------------------------ |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) | The control that was disposed. |

### ![](/files/KL0Ik37djZRr8a07Wopd) RunAsyncCore(control)

Asynchronously runs the core logic for generating an image based on the control's text.

| Parameter   | Type                                                      | Description                                  |
| ----------- | --------------------------------------------------------- | -------------------------------------------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) | The control containing the text description. |

**Returns:** [Task\<Message>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation, with a [Message](/ai/components/api/smartsession/wisej.ai.smartsession.message.md) result containing the generated image or image URL.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the control is null.

## Implements

| Name                                                                              | Description                                |
| --------------------------------------------------------------------------------- | ------------------------------------------ |
| [IToolProvider](/ai/components/api/smarttool/wisej.ai.smarttool.itoolprovider.md) | Represents a provider that supplies tools. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
