Click here to Skip to main content
15,923,197 members
Home / Discussions / C#
   

C#

 
Questionhow to save some file path in sql server 2000? Pin
nomsnoms20-Apr-06 9:23
nomsnoms20-Apr-06 9:23 
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 
Hi!

I need to flip or mirror a bitmap horizontally loading it from a file and saving the flipped one into another file.

I've seen some piece of code that is supposed to do this, but it uses "unsafe" code. Is there any way to do it without unsafe code?

Here's the code I found:

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


Thanx for any help!
AnswerRe: Invert Bitmap Pin
LongRange.Shooter20-Apr-06 7:42
LongRange.Shooter20-Apr-06 7:42 
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 

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.