Click here to Skip to main content
15,886,199 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to save some file path in sql server 2000? Pin
Guffa20-Apr-06 9:34
Guffa20-Apr-06 9:34 
QuestionD3D device problem - DirectX Pin
victor_ba8520-Apr-06 8:41
victor_ba8520-Apr-06 8:41 
AnswerRe: D3D device problem - DirectX Pin
Judah Gabriel Himango20-Apr-06 12:43
sponsorJudah Gabriel Himango20-Apr-06 12:43 
QuestionHELP! I'm stuck! Access credentials for network share Pin
chrisk7720-Apr-06 8:38
chrisk7720-Apr-06 8:38 
QuestionImporting MS Access Report in Crystal Reports XI Pin
Code Toad20-Apr-06 8:06
Code Toad20-Apr-06 8:06 
Questionprinting in a right-to-left language Pin
Green Fuze20-Apr-06 7:14
Green Fuze20-Apr-06 7:14 
QuestionInvert Bitmap Pin
sergestusxx20-Apr-06 7:11
sergestusxx20-Apr-06 7:11 
AnswerRe: Invert Bitmap Pin
LongRange.Shooter20-Apr-06 7:42
LongRange.Shooter20-Apr-06 7:42 
If you surround your code with <pre> and </pre> then the post will retain your spacing. So looking at your formatted code, I end up with mismatch squirrly brackets:

sergestusxx wrote:

public static bool Invert(Bitmap b)
{
    System.Drawing.Imaging.BitmapData bmData = 
      b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
      System.Drawing.Imaging.ImageLockMode.ReadWrite,
      System.Drawing.Imaging.PixelFormat.Format24bppRgb);
    int stride = bmData.Stride;
    System.IntPtr Scan0 = bmData.Scan0;
    unsafe
    {
        byte * p = (byte *)(void *)Scan0;
        int nOffset = stride - b.Width*3;
        int nWidth = b.Width * 3;
        for(int y=0;y {
        for(int x=0; x < nWidth; ++x )
        {
            p[0] = (byte)(255-p[0]);
            ++p;
        }
        p += nOffset;
    }
}

b.UnlockBits(bmData);
return true;
}
}



Looking at the code in general (ignoring the obvious) the reason your unsafe is due to the use of the pointer. (something prefered to be avoided when possible)

Having said that, it looks like it is the only way that you can turn a bitmap into an array-addressable object for inversion.

This looks like a case where unsafe is not avoidable.

-- modified at 13:44 Thursday 20th April, 2006
AnswerRe: Invert Bitmap Pin
Josh Smith20-Apr-06 7:44
Josh Smith20-Apr-06 7:44 
AnswerRe: Invert Bitmap Pin
Guffa20-Apr-06 8:07
Guffa20-Apr-06 8:07 
AnswerRe: Invert Bitmap Pin
Judah Gabriel Himango20-Apr-06 12:47
sponsorJudah Gabriel Himango20-Apr-06 12:47 
Questionregistering a dll at runtime Pin
shezh20-Apr-06 6:44
shezh20-Apr-06 6:44 
AnswerRe: registering a dll at runtime Pin
Le centriste20-Apr-06 7:05
Le centriste20-Apr-06 7:05 
Questionlate binding to VB6 dlls Pin
shezh20-Apr-06 6:11
shezh20-Apr-06 6:11 
Questioncreating a txt file Pin
john3420-Apr-06 5:42
john3420-Apr-06 5:42 
AnswerRe: creating a txt file Pin
J4amieC20-Apr-06 5:51
J4amieC20-Apr-06 5:51 
AnswerRe: creating a txt file Pin
AETaylor21-Apr-06 1:54
AETaylor21-Apr-06 1:54 
QuestionI/O Threading program Pin
eric_tran20-Apr-06 4:55
eric_tran20-Apr-06 4:55 
AnswerRe: I/O Threading program Pin
LongRange.Shooter20-Apr-06 7:10
LongRange.Shooter20-Apr-06 7:10 
Questioninsert in database Pin
guest_098720-Apr-06 4:34
guest_098720-Apr-06 4:34 
QuestionHTTP Sniffer Pin
ksor20-Apr-06 4:34
ksor20-Apr-06 4:34 
QuestionHow to update data from an access database? Pin
nulkoud20-Apr-06 4:30
nulkoud20-Apr-06 4:30 
QuestionHow to make Web Application more Secure in Asp.Net???? Pin
pal_vaidya20-Apr-06 4:14
pal_vaidya20-Apr-06 4:14 
AnswerRe: How to make Web Application more Secure in Asp.Net???? Pin
LongRange.Shooter20-Apr-06 7:26
LongRange.Shooter20-Apr-06 7:26 
QuestionCreating playlists Pin
mickeyfitzray20-Apr-06 3:21
mickeyfitzray20-Apr-06 3:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.