So yeah... stuff is hard

    Date: 01/26/06 (C Sharp)    Keywords: no keywords


    The method:

    		protected unsafe bool getBinaryAt(int x, int y, BitmapInfo img)
    		{
    			fixed (byte* scan0 = &img.pixelData[0])
    			{
    				byte pval = 0;
    
    
    				byte* pos = scan0 + y * img.Stride + x * getByteSize(img.Format);
    
    				pval = (byte)((*pos + *(pos + 1) + *(pos + 3)) / 3);
    
    
    				return (pval > THRESH);
    			}
    
    		}
    


    The problem:

    "AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

    You know what I hate more than anything right now? AccessViolationExceptions. I apparently don't know what I'm doing when it comes to working with images.





    Edit: Now with a question!!

    Is accessing an array element via pointer arithmetic faster than accessing it using [] syntax in C#? I ask because I'm trying this about 3 million times per second.

    Source: http://community.livejournal.com/csharp/48101.html

« some marshalling questions || Code analysis tool »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home