主题
获取OLA图像缩略图 - GetOlaImageThumbnail
函数简介
从OLA数据库中获取指定目录和文件名的图像缩略图(约 150px),返回缩略图图像对象的指针。
接口名称
GetOlaImageThumbnailDLL调用
cpp
long GetOlaImageThumbnail(long ola, const long db, string dir, string fileName);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整型数 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| db | 长整型数 | 数据库连接句柄,由 OpenDatabase 接口生成。 |
| dir | 字符串 | 图片目录路径。 |
| fileName | 字符串 | 图片文件名。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png");csharp
using OLAPlug;
var ola = new OLAPlugServer();
long handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png");go
import "github.com/ola/olaplug/olaplug"
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
handle := ola.GetOlaImageThumbnail(0, "icons", "logo.png")rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let handle = ola.get_ola_image_thumbnail(0, "icons", "logo.png");cpp
var ola = com("OlaPlug.OlaSoft")
var handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png")text
.局部变量 ola, OLAPlug
ola.创建 ()
handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png")aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long handle = ola.GetOlaImageThumbnail(0, "icons", "logo.png");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long handle = GetOlaImageThumbnail(instance, 0, "icons", "logo.png");
if (handle != 0) {
// 使用缩略图图像对象,例如预览或显示
FreeImagePtr(handle);
}csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeImagePtr(long handle);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetOlaImageThumbnail(long ola, long db, string dir, string fileName);
long instance = CreateCOLAPlugInterFace();
long handle = GetOlaImageThumbnail(instance, 0, "icons", "logo.png");
if (handle != 0) {
FreeImagePtr(handle);
}python
from ctypes import CDLL, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
handle = ola.GetOlaImageThumbnail(instance, 0, "icons", "logo.png")
if handle:
ola.FreeImagePtr(handle)返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 缩略图图像对象的指针。如果未找到或操作失败,返回 0。 |
注意事项
| 项目 | 说明 |
|---|---|
| 缩略图尺寸 | 返回的缩略图约为 150px,适用于列表预览、资源浏览等轻量场景。 |
| 与 GetOlaImage 的差异 | 若需完整原图数据,请使用 GetOlaImage。 |
| 如果图像不存在或操作失败 | 如果图像不存在或操作失败,可通过 GetDatabaseError 获取详细错误信息。 |
| 使用完返回的图像对象指针后 | 使用完返回的图像对象指针后,应妥善处理资源,避免内存泄漏。 |
