Win32 API 日本語リファレンス
ホームGraphics.GdiPlus › GdipLoadImageFromStream

GdipLoadImageFromStream

関数
ストリームから画像を読み込んでイメージオブジェクトを作成する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

// gdiplus.dll
#include <windows.h>

Status GdipLoadImageFromStream(
    IStream* stream,
    GpImage** image
);

パラメーター

名前方向説明
streamIStream*in画像データを読み込む元のIStreamインタフェースへのポインタ。
imageGpImage**inout生成された画像オブジェクトを受け取るGpImage**。

戻り値の型: Status

各言語での呼び出し定義

// gdiplus.dll
#include <windows.h>

Status GdipLoadImageFromStream(
    IStream* stream,
    GpImage** image
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipLoadImageFromStream(
    IntPtr stream,   // IStream*
    IntPtr image   // GpImage** in/out
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipLoadImageFromStream(
    stream As IntPtr,   ' IStream*
    image As IntPtr   ' GpImage** in/out
) As Integer
End Function
' stream : IStream*
' image : GpImage** in/out
Declare PtrSafe Function GdipLoadImageFromStream Lib "gdiplus" ( _
    ByVal stream As LongPtr, _
    ByVal image As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipLoadImageFromStream = ctypes.windll.gdiplus.GdipLoadImageFromStream
GdipLoadImageFromStream.restype = ctypes.c_int
GdipLoadImageFromStream.argtypes = [
    ctypes.c_void_p,  # stream : IStream*
    ctypes.c_void_p,  # image : GpImage** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipLoadImageFromStream = Fiddle::Function.new(
  lib['GdipLoadImageFromStream'],
  [
    Fiddle::TYPE_VOIDP,  # stream : IStream*
    Fiddle::TYPE_VOIDP,  # image : GpImage** in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipLoadImageFromStream(
        stream: *mut core::ffi::c_void,  // IStream*
        image: *mut *mut GpImage  // GpImage** in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipLoadImageFromStream(IntPtr stream, IntPtr image);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipLoadImageFromStream' -Namespace Win32 -PassThru
# $api::GdipLoadImageFromStream(stream, image)
#uselib "gdiplus.dll"
#func global GdipLoadImageFromStream "GdipLoadImageFromStream" sptr, sptr
; GdipLoadImageFromStream stream, varptr(image)   ; 戻り値は stat
; stream : IStream* -> "sptr"
; image : GpImage** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipLoadImageFromStream "GdipLoadImageFromStream" sptr, var
; res = GdipLoadImageFromStream(stream, image)
; stream : IStream* -> "sptr"
; image : GpImage** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipLoadImageFromStream(IStream* stream, GpImage** image)
#uselib "gdiplus.dll"
#cfunc global GdipLoadImageFromStream "GdipLoadImageFromStream" intptr, var
; res = GdipLoadImageFromStream(stream, image)
; stream : IStream* -> "intptr"
; image : GpImage** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipLoadImageFromStream = gdiplus.NewProc("GdipLoadImageFromStream")
)

// stream (IStream*), image (GpImage** in/out)
r1, _, err := procGdipLoadImageFromStream.Call(
	uintptr(stream),
	uintptr(image),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipLoadImageFromStream(
  stream: Pointer;   // IStream*
  image: Pointer   // GpImage** in/out
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipLoadImageFromStream';
result := DllCall("gdiplus\GdipLoadImageFromStream"
    , "Ptr", stream   ; IStream*
    , "Ptr", image   ; GpImage** in/out
    , "Int")   ; return: Status
●GdipLoadImageFromStream(stream, image) = DLL("gdiplus.dll", "int GdipLoadImageFromStream(void*, void*)")
# 呼び出し: GdipLoadImageFromStream(stream, image)
# stream : IStream* -> "void*"
# image : GpImage** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "gdiplus" fn GdipLoadImageFromStream(
    stream: ?*anyopaque, // IStream*
    image: [*c][*c]GpImage // GpImage** in/out
) callconv(std.os.windows.WINAPI) i32;
proc GdipLoadImageFromStream(
    stream: pointer,  # IStream*
    image: ptr GpImage  # GpImage** in/out
): int32 {.importc: "GdipLoadImageFromStream", stdcall, dynlib: "gdiplus.dll".}
pragma(lib, "gdiplus");
extern(Windows)
int GdipLoadImageFromStream(
    void* stream,   // IStream*
    GpImage** image   // GpImage** in/out
);
ccall((:GdipLoadImageFromStream, "gdiplus.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{GpImage}),
      stream, image)
# stream : IStream* -> Ptr{Cvoid}
# image : GpImage** in/out -> Ptr{GpImage}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GdipLoadImageFromStream(
    void* stream,
    void* image);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipLoadImageFromStream(stream, image)
-- stream : IStream*
-- image : GpImage** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipLoadImageFromStream = lib.func('__stdcall', 'GdipLoadImageFromStream', 'int32_t', ['void *', 'void *']);
// GdipLoadImageFromStream(stream, image)
// stream : IStream* -> 'void *'
// image : GpImage** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("gdiplus.dll", {
  GdipLoadImageFromStream: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.GdipLoadImageFromStream(stream, image)
// stream : IStream* -> "pointer"
// image : GpImage** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GdipLoadImageFromStream(
    void* stream,
    void* image);
C, "gdiplus.dll");
// $ffi->GdipLoadImageFromStream(stream, image);
// stream : IStream*
// image : GpImage** in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Gdiplus extends StdCallLibrary {
    Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class);
    int GdipLoadImageFromStream(
        Pointer stream,   // IStream*
        Pointer image   // GpImage** in/out
    );
}
@[Link("gdiplus")]
lib Libgdiplus
  fun GdipLoadImageFromStream = GdipLoadImageFromStream(
    stream : Void*,   # IStream*
    image : GpImage**   # GpImage** in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GdipLoadImageFromStreamNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef GdipLoadImageFromStreamDart = int Function(Pointer<Void>, Pointer<Void>);
final GdipLoadImageFromStream = DynamicLibrary.open('gdiplus.dll')
    .lookupFunction<GdipLoadImageFromStreamNative, GdipLoadImageFromStreamDart>('GdipLoadImageFromStream');
// stream : IStream* -> Pointer<Void>
// image : GpImage** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GdipLoadImageFromStream(
  stream: Pointer;   // IStream*
  image: Pointer   // GpImage** in/out
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipLoadImageFromStream';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GdipLoadImageFromStream"
  c_GdipLoadImageFromStream :: Ptr () -> Ptr () -> IO Int32
-- stream : IStream* -> Ptr ()
-- image : GpImage** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let gdiploadimagefromstream =
  foreign "GdipLoadImageFromStream"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* stream : IStream* -> (ptr void) *)
(* image : GpImage** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)

(cffi:defcfun ("GdipLoadImageFromStream" gdip-load-image-from-stream :convention :stdcall) :int32
  (stream :pointer)   ; IStream*
  (image :pointer))   ; GpImage** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GdipLoadImageFromStream = Win32::API::More->new('gdiplus',
    'int GdipLoadImageFromStream(LPVOID stream, LPVOID image)');
# my $ret = $GdipLoadImageFromStream->Call($stream, $image);
# stream : IStream* -> LPVOID
# image : GpImage** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型