473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problems saving an image to a memory stream.

Dear All,
I am having problems saving an image to a memory stream to use it in an
API function. The error occurs in the save method of the bitmap. It tells me
that the arguement cannot be optional, yet when I look in the object browser
it tells me that for the overloaded function I am using that I only need two
parameters for this particular function. If you have any help with this or
help on how to create an API comaptiple pointer to a System.IO.MemoryStream,
which was part of a previous post that I made, it would be greatly
appreciated. Thank you very much for your time and consideration in this
matter. Here is the code:
Public Function SaveImageToMem(ByVal ImageToConvert As Bitmap) As IntPtr

Try

Dim ImgMemStream As System.IO.MemoryStream

'Error Occurs After This line

ImageToConvert.Save(ImgMemStream, ImageToConvert.RawFormat) '<-
Error occurs here! Error is that an arguement cannot be null, yet I am using
this function correctly, what gives?

Dim PtrMemory As IntPtr =
Marshal.GetIDispatchForObject(ImgMemStream) '<- I am not sure if this is the
right way to to this, any help would be great, Thanks!

Return PtrMemory

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Critical, "Error Performing
Operation!")

End Try

End Function

And here is the API function that I want to pass the pointer to .... It is
part of the FreeImage Library, which you can download at
http://freeimage.sourceforge.net!

DLL_API Long *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif,
Long *stream, int flags FI_DEFAULT(0));
Nov 21 '05 #1
0 1153

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peder Y | last post by:
Say I have several images, a jpg a gif and a bmp. Now, I want to save these files to a single binary file. I store the images in, say, Image img1, img2, img3; 1) How can I retrieve the size...
4
by: CodeRazor | last post by:
I'm unfamiliar with image manipulation using c#. How can i resize a jpg that currently exists in a file and save it resized as a new file. The examples i've found have been a bit misleading for...
2
by: asad | last post by:
Hello friends, how ru all, i have some problem about saving created thumbnail, following is the code i use for creating thumbnail but thumbnail was not saved it is on memory which method is used to...
9
by: kombu67 | last post by:
I'm reading a series of images from a MS SQL table and saving them to directory. These are staff ID pictures from our security card app. Once I've extracted the ID photo from the security app to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.