473,404 Members | 2,195 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,404 software developers and data experts.

How to Get Image send by API

Hi,
I have a device that scan's a doc and send's the doc image back. Below is
the function in API to get the Image:

ULONG MTMICRGetImage (
char *pcDevName,
char *pcImageID,
char *pcBuffer,
DWORD *pwdLength
);

Example of using the function
===================
//Get the imgae size from function DocInfo
//Get the imgae ID from function DocInfo

//Allocate memory for image
ImageBuffer = (char*) VirtualAlloc (NULL, bufferSize, MEM_COMMIT,
PAGE_READWRITE);

//Use function MTMICRGetDevice to get device name for variable "Device"
//Get image from the device
MTMICRGetImage (Device, cValue, ImageBuffer, &bufferSize);
Nov 21 '05 #1
5 1703
Hi,

First I have to ask you a few questions:

- What's the "Image"? It it a text string, like description, or it's the
image (graphical)?
- Is the provided declaration located in docs or in C/C++ header file?
If it's in docs please provide the one in header.

And a few suggestions.

- If pcDevName and pcImageID are not going to be changed then declare
them as String rather then as StringBuilder. That's more handy!
- Try to declare pcBuffer as IntPtr (ByVal); then allocate memory using
Marshal.AllocHGlobal and call function with the buffer returned as an
argument. Then look in a memory window if image is actually put there,
and what does it looks like.

Roman

"AAVarda" <as***@data-aware.com> сообщил/сообщила в новостях следующее:
news:#w**************@TK2MSFTNGP14.phx.gbl...
Hi,
I have a device that scan's a doc and send's the doc image back. Below is the function in API to get the Image:

ULONG MTMICRGetImage (
char *pcDevName,
char *pcImageID,
char *pcBuffer,
DWORD *pwdLength
);

Example of using the function
===================
//Get the imgae size from function DocInfo
//Get the imgae ID from function DocInfo

//Allocate memory for image
ImageBuffer = (char*) VirtualAlloc (NULL, bufferSize, MEM_COMMIT,
PAGE_READWRITE);

//Use function MTMICRGetDevice to get device name for variable "Device" //Get image from the device
MTMICRGetImage (Device, cValue, ImageBuffer, &bufferSize);
.
.
.
//Free the memory
VirtualFree (ImageBuffer, bufferSize, MEM_DECOMMIT);
}
I am using this API function in VB .NET as mention below
=======================================
Declare Ansi Function fGetImage Lib "mtmcrapi.dll" Alias "MTMICRGetImage" (ByVal NameSB As StringBuilder, ByVal sbValue As StringBuilder, ByVal
sbImageData As StringBuilder, ByRef intImageSize As Integer) As Integer
Dim sbImage As New StringBuilder(37346)
dim rst as integer
rst = fGetImage(nameSB, sbImageUrl, sbImage, intImageSize)
MessageBox.Show(rst.ToString & "=" & sbImage.ToString, "Image Function")
My Doubts
=========
The function is returning value 0 that means running fine and
sbImage.ToString returns 4 junk characters.
-Am I going in right direction??
-What value is sbImage.ToString holding Pointer or the Image Bytes ??
-What should I do next to get the Image??

I would really appreciate anykind of help.Thank you.

Nov 21 '05 #2
Image is Graphical.I will try the other solution and let you know what
happens..Thank you

"Dragon" <no@spam.please> wrote in message
news:uC**************@TK2MSFTNGP15.phx.gbl...
Hi,

First I have to ask you a few questions:

- What's the "Image"? It it a text string, like description, or it's the
image (graphical)?
- Is the provided declaration located in docs or in C/C++ header file?
If it's in docs please provide the one in header.

And a few suggestions.

- If pcDevName and pcImageID are not going to be changed then declare
them as String rather then as StringBuilder. That's more handy!
- Try to declare pcBuffer as IntPtr (ByVal); then allocate memory using
Marshal.AllocHGlobal and call function with the buffer returned as an
argument. Then look in a memory window if image is actually put there,
and what does it looks like.

Roman

"AAVarda" <as***@data-aware.com> сообщил/сообщила в новостях следующее:
news:#w**************@TK2MSFTNGP14.phx.gbl...
Hi,
I have a device that scan's a doc and send's the doc image back. Below

is
the function in API to get the Image:

ULONG MTMICRGetImage (
char *pcDevName,
char *pcImageID,
char *pcBuffer,
DWORD *pwdLength
);

Example of using the function
===================
//Get the imgae size from function DocInfo
//Get the imgae ID from function DocInfo

//Allocate memory for image
ImageBuffer = (char*) VirtualAlloc (NULL, bufferSize, MEM_COMMIT,
PAGE_READWRITE);

//Use function MTMICRGetDevice to get device name for variable

"Device"
//Get image from the device
MTMICRGetImage (Device, cValue, ImageBuffer, &bufferSize);
.
.
.
//Free the memory
VirtualFree (ImageBuffer, bufferSize, MEM_DECOMMIT);
}
I am using this API function in VB .NET as mention below
=======================================
Declare Ansi Function fGetImage Lib "mtmcrapi.dll" Alias

"MTMICRGetImage"
(ByVal NameSB As StringBuilder, ByVal sbValue As StringBuilder, ByVal
sbImageData As StringBuilder, ByRef intImageSize As Integer) As

Integer

Dim sbImage As New StringBuilder(37346)
dim rst as integer
rst = fGetImage(nameSB, sbImageUrl, sbImage, intImageSize)
MessageBox.Show(rst.ToString & "=" & sbImage.ToString, "Image

Function")

My Doubts
=========
The function is returning value 0 that means running fine and
sbImage.ToString returns 4 junk characters.
-Am I going in right direction??
-What value is sbImage.ToString holding Pointer or the Image Bytes ??
-What should I do next to get the Image??

I would really appreciate anykind of help.Thank you.


Nov 21 '05 #3
Just to make things clear, below example of using the function was given in
the Device's programmers Manual

ULONG MTMICRGetImage (char *pcDevName,char *pcImageID,char *pcBuffer,DWORD
*pwdLength)
..
..
..
..
Example:
//Get the imgae size from function DocInfo
//Get the imgae ID from function DocInfo

//Allocate memory for image
ImageBuffer = (char*) VirtualAlloc (NULL, bufferSize, MEM_COMMIT,
PAGE_READWRITE);

//Use function MTMICRGetDevice to get device name for variable
"Device"
//Get image from the device
MTMICRGetImage (Device, cValue, ImageBuffer, &bufferSize);
Nov 21 '05 #4

"AAVarda" <as***@data-aware.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Just to make things clear, below example of using the function was given
in the Device's programmers Manual

ULONG MTMICRGetImage (char *pcDevName,char *pcImageID,char *pcBuffer,DWORD
*pwdLength)
.
.
.
.
Example:
//Get the imgae size from function DocInfo
//Get the imgae ID from function DocInfo

//Allocate memory for image
ImageBuffer = (char*) VirtualAlloc (NULL, bufferSize, MEM_COMMIT,
PAGE_READWRITE);

//Use function MTMICRGetDevice to get device name for variable
"Device"
//Get image from the device
MTMICRGetImage (Device, cValue, ImageBuffer, &bufferSize);
.
.
.
//Free the memory
VirtualFree (ImageBuffer, bufferSize, MEM_DECOMMIT);
}

I wrote the above API function in VB .NET as mention below
=======================================
Declare Ansi Function fGetImage Lib "mtmcrapi.dll" Alias "MTMICRGetImage"
(ByVal NameSB As StringBuilder, ByVal sbValue As StringBuilder, ByVal
sbImageData As StringBuilder, ByRef intImageSize As Integer) As Integer

Dim sbImage As New StringBuilder(37346)
dim rst as integer
rst = fGetImage(nameSB, sbImageUrl, sbImage, intImageSize)
MessageBox.Show(rst.ToString & "=" & sbImage.ToString, "ImageFunction")

My Doubts
=========
The function is returning value 0 that means running fine and
sbImage.ToString returns 4 junk characters.
-According to the Manual Example what is the ImageBuffer HOLDING ???
That's the question. What image format does ImageBuffer hold ?
- a fileformat like bmp, gif, jpg etc or
- a DIB with a BITMAPINFO structure or
- only pixel data (then you need to know height, width, stride, colorformat
(RGB24, RGB16, etc)) and compression or
- maybe something else ...

Can't you find any clues in the documenation for the library ?

HTH,
Greetings
-I tried by change the the datatype for the parameter sbImageData from
StringBuilder to IntPrt but got the error:

System.NullReferenceException: Object reference not set to an instance of
an object.
at Exella.Win32.fGetImage(StringBuilder NameSB, StringBuilder sbValue,
IntPtr sbImageData, Int32& intImageSize)
at Exella.Form1.Button1_Click(Object sender, EventArgs e) in
F:\Ali\Exella\Form1.vb:line 214

What should I do to get the Image??

I would really appreciate anykind of help.Thank you.

Nov 21 '05 #5
You should look into what manual says about using the image that is
retrieved by call to MTMICRGetImage. What happens to it after it's
retrieved?

You may also try to translate C example line by line, i.e. with
VirtualAlloc etc.

~
Friend Declare Function VirtualAlloc Lib "kernel32.dll" ( _
ByVal lpAddress As IntPtr, _
ByVal dwSize As Integer, _
ByVal flAllocationType As Integer, _
ByVal flProtect As Integer _
) As IntPtr

Friend Declare Function VirtualFree Lib "kernel32.dll" ( _
ByVal lpAddress As IntPtr, _
ByVal dwSize As Integer, _
ByVal dwFreeType As Integer _
) As Boolean
~

Roman

"AAVarda" <as***@data-aware.com> сообщил/сообщила в новостях следующее:
news:#N**************@tk2msftngp13.phx.gbl...
Just to make things clear, below example of using the function was given in the Device's programmers Manual

ULONG MTMICRGetImage (char *pcDevName,char *pcImageID,char *pcBuffer,DWORD *pwdLength)
.
.
.
.
Example:
//Get the imgae size from function DocInfo
//Get the imgae ID from function DocInfo

//Allocate memory for image
ImageBuffer = (char*) VirtualAlloc (NULL, bufferSize, MEM_COMMIT,
PAGE_READWRITE);

//Use function MTMICRGetDevice to get device name for variable
"Device"
//Get image from the device
MTMICRGetImage (Device, cValue, ImageBuffer, &bufferSize);
.
.
.
//Free the memory
VirtualFree (ImageBuffer, bufferSize, MEM_DECOMMIT);
}

I wrote the above API function in VB .NET as mention below
=======================================
Declare Ansi Function fGetImage Lib "mtmcrapi.dll" Alias "MTMICRGetImage" (ByVal NameSB As StringBuilder, ByVal sbValue As StringBuilder, ByVal
sbImageData As StringBuilder, ByRef intImageSize As Integer) As Integer
Dim sbImage As New StringBuilder(37346)
dim rst as integer
rst = fGetImage(nameSB, sbImageUrl, sbImage, intImageSize)
MessageBox.Show(rst.ToString & "=" & sbImage.ToString, "ImageFunction")
My Doubts
=========
The function is returning value 0 that means running fine and
sbImage.ToString returns 4 junk characters.
-According to the Manual Example what is the ImageBuffer HOLDING ???
-I tried by change the the datatype for the parameter sbImageData from
StringBuilder to IntPrt but got the error:

System.NullReferenceException: Object reference not set to an instance of an object.
at Exella.Win32.fGetImage(StringBuilder NameSB, StringBuilder sbValue, IntPtr sbImageData, Int32& intImageSize)
at Exella.Form1.Button1_Click(Object sender, EventArgs e) in
F:\Ali\Exella\Form1.vb:line 214

What should I do to get the Image??

I would really appreciate anykind of help.Thank you.

Nov 21 '05 #6

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

Similar topics

9
by: Deepa | last post by:
Hi All, I'm facing problem displaying image of size 5000X5000 .My window size is smaller than image size so i'm not able to see the complete image.i can use scroll bars to view the image but i...
4
by: CG3000 | last post by:
I create a .PNG image ( in Macromedia Fireworks ) which has an gif in it in the top left corner and a lot of empty canvas space to the right. I use about 10 text boxes on a form to populate...
2
by: eSolTec, Inc. 501(c)(3) | last post by:
I'm looking for code samples to send a jpg image from a client machine to a host machine. Both have the same image picWindows picture container. I would like to be able to send the image on one...
19
by: amit | last post by:
Hi group, Long story short, I'm new to JavaScript and have started it less than 3 weeks. My question is 1) how can I create a situation that when user clicks on gif or ... image file an event...
24
by: Manuel | last post by:
Is it possible to embed an image, like a company logo in a CDOSYS generated message? If yes, IВґll apreciate some code sample. IВґve been able to format messages in html the way I like, but I...
3
by: Senthil | last post by:
Hi all I'm new in ajax. How to upload a image using ajax..
1
by: Ray Schumacher | last post by:
I'm trying to make a small camera server using VideoCapture.py and socket. I needed to construct a complete image file with headers etc for a browser to recognize it, but I couldn't find a...
1
by: sergiotb | last post by:
Hello everyone!! I'm trying to send a image (jpg) from a C# program to a CGI perl. The problem is that the code of the client C# is not working properly...I guess. The steps to send the image are: 1)...
1
by: keksy | last post by:
Hi every1, I am writing a small client/server application and in it I want to send an image asynchronous from the client to the server through a TCP socket. I found an example code on the MSDN...
3
by: FFMG | last post by:
Hi, I want to send expiry headers along with my images. This is the code in my .htaccess file Code: -------------------- ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.