skinnysoli.blogg.se

Ipicture msdn
Ipicture msdn





ipicture msdn

'Create a bitmap handle from the GDI image LResult = GdipCreateBitmapFromFile(StrPtr(sFilename), hGdiImage) LResult = GdiplusStartup(hGdiPlus, uGdiInput) Public Sub LoadPictureGDI(ByVal c As Object, ByVal sFilename As String) ' Returns: The image as an IPicture Object Private Sub showImage(ByVal path As String) Private Declare Function OleCreatePictureIndirect Lib "oleaut32" (PicDesc As PICTDESC, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As LongĪnd here the methods: Showing the image with the given path Private Declare Sub GdiplusShutdown Lib "GDIPlus" (ByVal token As Long) Private Declare Function GdipDisposeImage Lib "GDIPlus" (ByVal image As Long) As Long Private Declare Function GdipCreateHBITMAPFromBitmap Lib "GDIPlus" (ByVal bitmap As Long, hbmReturn As Long, ByVal background As Long) As Long Private Declare Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal filename As Long, bitmap As Long) As Long Private Declare Function GdiplusStartup Lib "GDIPlus" (token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long Private Declare PtrSafe Function OleCreatePictureIndirect Lib "oleaut32" (PicDesc As PICTDESC, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long Private Declare PtrSafe Sub GdiplusShutdown Lib "GDIPlus" (ByVal token As LongPtr) Private Declare PtrSafe Function GdipDisposeImage Lib "GDIPlus" (ByVal image As LongPtr) As Long Private Declare PtrSafe Function GdipCreateHBITMAPFromBitmap Lib "GDIPlus" (ByVal bitmap As LongPtr, hbmReturn As LongPtr, ByVal background As LongPtr) As Long Private Declare PtrSafe Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal filename As LongPtr, bitmap As LongPtr) As Long Private Declare PtrSafe Function GdiplusStartup Lib "GDIPlus" (token As LongPtr, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As LongPtr = 0) As Long 'Declare a UDT to store the GDI+ Startup information 'Declare a UDT to store the bitmap information 'Declare a UDT to store a GUID for the IPicture OLE Interface

IPICTURE MSDN CODE

The following code declares all libraries. Both are loaded to a frame with the size 400x192. The first one has the size 1920x921 (reduced automatically from frame control), the second one 400x192 (reduced with paint). Here are two png version of the linked picture i found on google. Is there any other way to reduce the size of an image with VBA and keep it readable? If I change the size with paint and load the image afterwards to the userform it looks exactly like I want, but this is not a solution for me! At least the description header should be readable. The images contain some measure plots with description labels and legends on it. Unfortunately the picture is still unreadable and looks the same as with the other approaches. I used a spy program to determine the handle of my frame and then rendered the image with a lower resolution. The same effect happens if i use fmPicturesizeModeClip and reduce the zoom value.Īfter searching the web I found some posts about the render method ( IPicture::Render (MSDN)). It seems that the PictureSizeModeZoom is distorting the image. My first approach was to set the PictureSizeMode, but the PNG becomes unreadable. 1600x1200) and I want to resize the images. My problem is that the images have a large resolution (e.g. These works fine and the picture is displayed correctly. Afterwards I just have to set the IPicture object to the Picture property of the control. Therefore I use a frame control.īecause most of the pictures are png's, I use the GDI libraries to load the file as a bitmap and convert it to an IPicture object. After an entry becomes selected, the picture should be displayed in the userform (like a preview). The filenames are stored in a listbox and the absolute paths in a collection. I created an userform in Powerpoint (2016) which allows the user to select some pictures with a filedialog.







Ipicture msdn