|
Use
DG_IMAGE / DAT_IMAGENATIVEXFER / MSG_GET
this source store image in BGR format in the buffer.
Regards
Anil
|
|
|
|
|
i AM using imagenativexfer. the data i am getting is RGB.
|
|
|
|
|
Hi
According to TWAIN specification
Notes:
· Do not use BITMAPCOREINFO or BIMAPCOREHEADER as these are for OS/2
compatibility only.
· Always follow the BITMAPINFOHEADER with the color table and only save 1, 4, or 8
bit DIBs
· Color table entries are RGBQUADs, which are stored in memory as BGR not RGB.
· For 24 bit color DIBs, the "pixels" are also stored in BGR order, not RGB.
· DIBs are stored ‘upside-down’ - the first pixel in the DIB is the lower-left corner of the
image, and the last pixel is the upper-right corner.
· DIBs can be larger than 64K, but be careful, a 24 bit pixel can straddle a 64K boundary!
· Pixels in 1, 4, and 8 bit DIBs are "always" color table indices, you must index through
the color table to determine the color value of a pixel.
Regards
Anil
|
|
|
|
|
Thanks for answering!
I got a little confused. I'm sorry.
I mean I was using the buffered transfer mode.
ICAP_XFERMECH, TWSX_MEMORY
This is because the images can get really really really large.
For ImageNativeXfer, you are right. It returns the proper Bitmap. However ICAP_XFERMECH, TWSX_MEMORY returns RGBs.
I've found a possible solution of using ColorMatrixEffect in GDI+....if only Microsoft REMEMBERED to include GdiPlusEffects.h in the SDK.
Do you have other ideas?
|
|
|
|
|
Hi everyone,
i dont have any experience in VC++.I know some C and C++, thats all.May be silly,but out of curiosity I am asking this question.
If we delare a pointer as
int * p ,it will create an integer pointer p.It will reserve 2 bytes in memory also.How this two memory locations and *p is tagged together or who is allocating these memory locations to p(Like,the rule p should hold only addresses).
say the locations are 1000 and 1001.
consider this, and please check my interpretations are correct or not;
int j;
*p=2; // integer 2 is stored in 1000 and 1001 as(0000 0010)
(will this work .here p does not hold any address value and storing value 2 directly in their address space)
printf("%d",p) //prints 1000
p=&j; // now doubt,here how 1000,1001 store the address of j
j=4; // *p and j will print the same value.
Please give your comments about this or please direct me if you know some good stuffs regarding the memory concepts in programming.
Thank you
-- modified at 0:55 Friday 26th May, 2006
|
|
|
|
|
|
It's all pretty simple, once you get the hang of it.
When you declare a pointer, the compiler allocates a certain number of bytes (depending on the platform) on the stack. The size of the pointer is derived from the maximum address space that it can point to. In a 32 bit environment running Windows, each process gets 4GB of address space, so a pointer must be big enough to point at any address from 0 to 0xFFFFFFFF. The size of the pointer is therefore log2(4294967296), which is equal to 32 bits. You can do the same calculation for a 64 bit environment.
This memory allocated by the compiler holds the address of whatever the pointer is pointing to, at runtime.
jithAtran - ii wrote: *p=2; // integer 2 is stored in 1000 and 1001 as(0000 0010)
I don't get what 1000 and 1001 are. If you consider them to be address of the pointer itself (&p), then your comment is incorrect. If you consider them to be the address where the pointer is pointing at, then your interpretation is correct. I'll assume you meant the latter.
jithAtran - ii wrote: p=&j; // now doubt,here how 1000,1001 store the address of j
All this does is change where p is pointing at. p will no longer hold 1000/1001, instead, it will hold whatever is the address of j (2000, 2001, for example). That explains why *p and j hold the same value.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thank you Senthil,
for the detailed reply.
S. Senthil Kumar wrote: jithAtran - ii wrote:
*p=2; // integer 2 is stored in 1000 and 1001 as(0000 0010)
I don't get what 1000 and 1001 are. If you consider them to be address of the pointer itself (&p), then your comment is incorrect. If you consider them to be the address where the pointer is pointing at, then your interpretation is correct. I'll assume you meant the latter.
No I assumed the address of P itself as 1000/1001.what will happen then if we do * p=2;
S. Senthil Kumar wrote: jithAtran - ii wrote:
p=&j; // now doubt,here how 1000,1001 store the address of j
All this does is change where p is pointing at. p will no longer hold 1000/1001, instead, it will hold whatever is the address of j (2000, 2001, for example). That explains why *p and j hold the same value
I know both p and j hold the same value.
I think I should state my silly doubt more clearly,
if p is a ponter it should hold the address
p=&j //should hold the address 2000/2001 as in your example.
the address of p is 1000/1001 and how it store the addresses 2000/2001 in bit format considering 1000 will hold 4 bits and 1001 will also hold 4 bits
Thank you again.
|
|
|
|
|
jithAtran - ii wrote: the address of p is 1000/1001 and how it store the addresses 2000/2001 in bit format considering 1000 will hold 4 bits and 1001 will also hold 4 bits
Like I said in my previous post, the size of a pointer is dependent on the platform. And address is different from the size of a variable. On Win32, a pointer is 4 bytes. If the address of p is 1000, then bytes 1000, 1001, 1002 and 1003 will be available for p. 4 bytes is equal to 32 bits and 232 is the maximum address value you can point at.
Taking your example, assuming a 16 bit environment, then the address of p will be 1000 and it will have two bytes allocated to it, 1000 and 1001. A byte is 8 bits, so 1000 can store 8 bits and 1001 can store 8 bits, for a total of 16 bits. For storing 2000, depending on the endianness, the compiler might do
<pre>
_________________
__00___|___7D_____
1000 1001
</pre>
7D is 2000 expressed in hex.
Does this answer your question?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks for the reply,
Now I am getting some clues about this and I am recalling my digital electronics lessons.Dont mind when I ask about the basics.I am more with asp.net
S. Senthil Kumar wrote: A byte is 8 bits
Oh...it was my mistake But I knew that
Now the only doubt would be about the declaration.
int *p ,float *q //integer pointer.
int i // normal integer.
regardless of the datatype compiler would allocate 4 bytes to p and q.
say 1000/1001 holds an address where an integer is stored.Where would the information about the data type be stored.
since 1000/1001 stores only points to some address location where the information regarding "*p='c' should not be allowed" willbe stored.
Does the compiler holds anything like a stack to store the datatype?
(I hope you will get my mind..I feel I have not clearly stated it ...)
Thanks
-- modified at 5:07 Friday 26th May, 2006
|
|
|
|
|
jithAtran - ii wrote: Does the compiler holds anything like a stack to store the datatype?
No, and there is no reason to. At compile time, the compiler knows that p is a pointer to int and q is a pointer to float, so when you do *p or *q, it knows how many bytes to read to get the value, so it generates code to do that. So if you write to a pointer with code like *p = 2 it generates code to write to the first four (or two, in your example) bytes of the address pointed to by p.
So yeah, at runtime, there is no information available about the pointer. The compiler cannot prevent code like this from crashing
char a = 'a';
char *pChar = &a;
void *pVoid = pChar;
int *pInt = (int *)pVoid;
*pInt = 12345; At runtime, the last line will cause problems, as 4 bytes will be written where only one byte has been allocated. The compiler cannot catch such problems, because it does not store the information anywhere.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
So i am trying to summarize my doubts.Correct me if I am wrong...
int *i;
static float *k;
int j;
i=&j;
k=&j;
printf("%d ,%f",*i,*k)
The procedure would be like this
compiler allocates 4 bytes each for pointer i and integer j. and when we prints i and k compiler reads byte information fromthe same or contigious addresses with respect to the datatype.
I still have doubt in this part.How compiler knows i is an integer.where the command "You should read only 4 bytes for i since its an integer" is stored.
of course we have declared like int *i and it stores only an address space.Will it throw error if we performed like this.
float q;
i=&q;
Thank you
-- modified at 5:34 Friday 26th May, 2006
|
|
|
|
|
jithAtran - ii wrote: I still have doubt in this part.How compiler knows i is an integer.where the command "You should read only 4 bytes for i since its an integer" is stored.
First, i is not an integer, it is a pointer to an integer. Second, the compiler does NOT store the information anywhere, it simply uses the information when it generates the machine code. When the compiler parses the program, it knows that i is of type int * , so it knows that whatever i is pointing at is an integer. Whenever it sees it being referenced/dereferenced, it uses that fact that i is a pointer to an integer to generate the correct code. To summarize, the information that i is a pointer to an integer is not stored anywhere, the compiler just generates code that treats i as a pointer to an integer.
jithAtran - ii wrote: Will it throw error if we performed like this.
float q;
i=&q;
Yes, it will. Like I said, at compile time, the compiler knows that i is a pointer to an integer, so it obviously won't allow it to point at a float.
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
Thank you Senthil,
Now I think I am pretty clear about these concepts .Yeterday, I referred the book of computer organization by hamacher and pointers in C.Your explanations helped me to sum up the things logically.
yeah ..But ..only this
S. Senthil Kumar wrote: the compiler knows that i is a pointer to an integer
How?
Correct me if I am wrong,
Lets declare like
int *i;
compiler parses this.
That means i has been given an address space in the memory(1000/1001).
Now we are trying to store an address say
like
______________
__00__|___7D__ where 007D is the address of a
1000 1001 float variable.
Now here is my doubt.How compiler knows this assignment is wrong.Obviously,it is the alloted space for an intger.But how does compiler keeps track that 1001/1002 are for integer.
i am sorry,I think ,i have to still understand the concepts
Thank you.
|
|
|
|
|
jithAtran - ii wrote: That means i has been given an address space in the memory(1000/1001).
Now we are trying to store an address say
like
______________
__00__|___7D__ where 007D is the address of a
1000 1001 float variable.
Now here is my doubt.How compiler knows this assignment is wrong.
Well, you're not doing
int *p = 0x007D;
are you? You are attempting to assign the address of a float variable to an integer pointer, so that's why the assignment is wrong.
The compiler knows this because, when it compiles code, it keeps track of the type of all variables, using something called a symbol table[^]. When it's time to generate code, it sees this line
float k = 10.0;
int *p = &k;
it realizes that p is a pointer to int and k is a float and therefore generates an error. If you want to know how it gets that information from the source code, google for "Parsing and Syntax Analysis", which is a pretty huge topic in itself.
Again, the compiler doesn't know addresses 1001/1002 are for pointing to integers, rather, it only knows that p is a pointer to an integer. The absolute address of the pointer itself is determined at runtime.
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
thanks senthil,
Now I got the clue.I was also googling to know more abou this.And I thought I am pretty clear on the topic now and took the C test of brainbench(Don't misunderstand. that was not my aim).
But Failed!!!! I got only 2.72 where the cut off mark was 2.75.
They said I was weak in pointers and functions..
Ok ...thanks for the help
[modified at 5.34 Indian Time]
Yeah..I got through this time .Thank you...
[/modified]
-- modified at 8:07 Saturday 27th May, 2006
|
|
|
|
|
In general what you say is correct. I have a minor correction to the following however:
S. Senthil Kumar wrote: the compiler allocates a certain number of bytes (depending on the platform) on the stack.
This is not always the case: the pointer need not be allocated on the stack. In fact the allocation of storage is an issue that concerns any variable and not just pointers. Consider the following:
struct Data
{
int number;
int *pNumber;
};
void Function()
{
Data IsOnTheStack;
}
Data InDataSegment;
Data *pData = new Data;
So in short pointers need not be on the stack and in fact where they are is not related to the fact they are pointers but the context.
Steve
|
|
|
|
|
Stephen Hewitt wrote: This is not always the case: the pointer need not be allocated on the stack.
Agreed. I just didn't want to confuse the OP more by attempting to explain where pointers themselves are allocated
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
hi,
pointer holds the address of a variable.
u r saying that integer 2 is stored in 1000 and 1001 as 0000 0010.
Now p points to 1000, which is the base address of integer 2.
In the case of p=&j
j=4;
pointer will be adjusted to the address of j. Hence *p and j will prints the same value.
|
|
|
|
|
int * p ;
//"say the locations are 1000 and 1001."-it's ok..
//that means The locations 1000 and 1001 are rady to hold address
//of an integer. If write
*p=2; //means you are trying to assign integer value on the address
//which is store on 1000 and 1001.
//So it will cause acess violation.at run time.
// we can do this after assign p=&j;
p=&j;
//Then
*p=2;
//means the Now 1000 and 1001 is holding the address of "j";
//And the value of that Address will be 2;
//Now *p and j will print the same value.
Saday Chand Sarkar
Software Engineer
Trek Technology(s)Pte.Ltd.
|
|
|
|
|
Thank you.I have doubt only in the memory part..I think I understand how values are being manupulated through pointers
can we do like this...
int *p,x // allocating 4 bytes for pinter p in memory;
float k //allocating 4 bytes.
p=&k // this will work very well.
Now,
k=&p // what will happen now
or k=&x;// if k has enough space to store the address of it can hold.
But then
*k should work ,I know,which will not
Thanks
-- modified at 3:15 Friday 26th May, 2006
|
|
|
|
|
An int* pointer can not (without perverse casting) point to a float. Simple pointers like the ones you're using will always be a fixed size; on 32-bit Windows this will be 4 bytes. The actual value of a pointer (the bit pattern in memory) indicates a location in memory where some data starts; the type of the pointer tells the compiler what type of data to expect. The example you gave will not compile - BUT if it did this is what it would be saying:
Make the pointer "p" point the data for the variable "k". When the user indirects through the pointer "p" treat the data as if it was an integer.
Steve
|
|
|
|
|
Thank you stephen,
Your reply forcing me to study stack and heap concepts of memory more deeply, though I know it theoratically.It would be nice,If you can point me to some good stuffs and articles.
Thank you...
|
|
|
|
|
hi,
I was facing a problem while i was developing a code, which should run on different OS like linux and windows. The only function in linux for which i could not find a windows equivalent was gettimeofday() which returns the system time. My only requirement in windows code is that I donot want any dependency on windows libraries. So, though there exists many functions in windows libraries to retrieve the system time, they all require either windows.h or some other specific windows based headers which i dont want.
So can anybody suggest an alternate to gettimeofday() which does NOT have any dependency on windows whatsoever but is a plain c/c++ implementation.
Thanks in advance for any help.
|
|
|
|
|
use SYSTEMTIME structure or CTime
Cheers
"Peace of mind through Technology"
|
|
|
|
|