OleLoadPicture解释

OleLoadPicture

Creates a new picture object and initializes it from the contents of a stream. This is equivalent to calling OleCreatePictureIndirect(NULL, ...) followed by IPersistStream::Load.

STDAPI OleLoadPicture(

  IStream * pStream,

               //Pointer to the stream that contains picture's data

               //指向包含图片数据的流

  LONG lSize,  //Number of bytes read from the stream

               //读取pStream字节的长度

  BOOL fRunmode,

               //The opposite of the initial value of the picture's

               // property

               //与图片属性的初始化值相反

  REFIID riid, //Reference to the identifier of the interface

               // describing the type of interface pointer to return

               //接口的参考类型,返回描述类型接口指针

  VOID ppvObj  //Address of output variable that receives interface

               // pointer requested in riid

               //返回指向需要riid的接口指针,为输出值

);

Parameters

pStream

[in] Pointer to the stream that contains the picture's data.

lSize

[in] Number of bytes that should be read from the stream, or zero if the entire stream should be read.

fRunmode

[in] The opposite of the initial value of the KeepOriginalFormat property. If TRUE, KeepOriginalFormat is set to FALSE and vice-versa.

//主要是和KeepOriginalFormat的属性相反

riid

[in] Reference to the identifier of the interface describing the type of interface pointer to return in ppvObj.

ppvObj

[out] Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvObj contains the requested interface pointer on the storage of the object identified by the moniker. If *ppvObj is non-NULL, this function calls IUnknown::AddRef on the interface; it is the caller's responsibility to call IUnknown::Release. If an error occurs, *ppvObj is set to NULL.

Return Values

This function supports the standard return values E_OUTOFMEMORY and E_UNEXPECTED, as well as the following:

S_OK

The picture was created successfully.

E_POINTER

The address in pStream or ppvObj is not valid. For example, either may be NULL.

E_NOINTERFACE

The object does not support the interface specified in riid.

Remarks

The stream must be in BMP (bitmap), WMF (metafile), or ICO (icon) format. A picture object created using OleLoadPicture always has ownership of its internal resources (fOwn==TRUE is implied).

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MFC是微软基于C++开发的图形用户界面(GUI)应用程序框架。要将图片内容转换为Base64格式,可以使用MFC框架中的功能和类来实现。 首先,我们需要使用MFC的CImage类读取图片文件,并将其加载到内存中。可以使用Load函数来实现这一步骤,例如: CImage image; if (image.Load(_T("image.jpg")) == S_OK) { // 图片加载成功 } else { // 图片加载失败 } 接下来,我们可以使用MFC的CComPtr类来操作图像数据并转换为Base64格式。首先,使用GetPixelAddress函数获取图像的像素数据的起始地址。然后,可以使用CComPtr的Attach函数将图像数据绑定到CComPtr对象上,将图像数据作为CComPtr对象的原始数据。最后,使用CBase64Encoder类将图像数据转换为Base64格式。 以下是示例代码: CImage image; if (image.Load(_T("image.jpg")) == S_OK) { // 获取图像数据的大小和像素数据的起始地址 int width = image.GetWidth(); int height = image.GetHeight(); int pitch = image.GetPitch(); BYTE* imageData = (BYTE*)image.GetPixelAddress(0, 0); // 将图像数据绑定到CComPtr对象上 CComPtr<IStream> stream; CreateStreamOnHGlobal(NULL, TRUE, &stream); CComPtr<IPicture> picture; OleLoadPicture(stream, size, FALSE, IID_IPicture, (void**)&picture); picture->put_Handle((OLE_HANDLE)imageData); // 将图像数据转换为Base64格式 CBase64Encoder base64Encoder; base64Encoder.Attach(stream); base64Encoder.Encode(); // 获取转换后的Base64字符串 CStringA base64String; base64Encoder.GetBase64String(base64String); } 以上示例代码是将图片内容转换为Base64格式的一个基本思路,并且使用了MFC框架中的CImage、CComPtr和CBase64Encoder等类来实现。具体的实现方式可能会根据实际需求而有所调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值