|
-
Sep 13th, 2003, 10:16 PM
#1
question about a code...
PHP Code:
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
unsafe
{
byte * p = (byte *)(void *)Scan0;
.
.
.
what does that red line exactly do? I know it declares a pointer p, but what does the "(void *)" on the right side of the equal sign do?
also, it accesses p like an array (ie, p[0] ) why is that?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 14th, 2003, 09:47 AM
#2
-
Sep 14th, 2003, 09:48 AM
#3
yay gay
(*void) if i am not in error that will cast it to a pointer type var and (byte*) will finally cast it to a byte pointer
\m/  \m/
-
Sep 14th, 2003, 02:07 PM
#4
aha ok. (yeah it wouldnt let me colorize it for some reason)
weird though, so you have to convert it to pointer first, then to a byte-pointer? why cant you just convert it directly to a byte-pointer
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 14th, 2003, 06:41 PM
#5
ok forget about that
how about my last question?
why is it accessing it with p[0] like an array?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 15th, 2003, 02:13 AM
#6
Coloring doesn't work in PHP tags, use CODE tags instead.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 15th, 2003, 11:29 AM
#7
Originally posted by CornedBee
Coloring doesn't work in PHP tags, use CODE tags instead.
aaha ok
as for the other question I had, I think p[0] just means the pointer at its current location, p[1] would be the next position in the memory... just a guess, because that's how it seems to be working
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 16th, 2003, 01:53 AM
#8
Yes, it works the same as in C++.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 16th, 2003, 04:12 PM
#9
umm another question
how come I can say if (p==null) ...
but not if (p[2]==null) ...
it gives this error for the second one
Operator '==' cannot be applied to operands of type 'byte' and '<null>'
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 17th, 2003, 06:12 AM
#10
Because a byte value can never be null, and p[2] is a byte value.
A pointer however can be null, and p is a pointer.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 17th, 2003, 09:59 AM
#11
Originally posted by CornedBee
Because a byte value can never be null, and p[2] is a byte value.
A pointer however can be null, and p is a pointer.
hmm so this way the value of p will be (byte)p ?
also, how would I check to see if p[2] exists or not?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 17th, 2003, 11:47 AM
#12
hmm so this way the value of p will be (byte)p ?
Huh? (byte)p might compile, but it certainly will not yield anything of any sense.
also, how would I check to see if p[2] exists or not?
You can't. The thing of pointers is that they are simply that: pointers. They store a memory address and NOTHING else. Why do you think you can only use them in unsafe areas? To know if accessing p[2] is valid, you need to store the length of the array that is pointed to by p separatly.
The maximum value you may use inside the square brackets is (Stride * Height) - 1
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 17th, 2003, 12:23 PM
#13
-
Sep 17th, 2003, 01:21 PM
#14
Learn plain old-school C and you'll know all about them
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|