Click here to Skip to main content
15,914,481 members
Home / Discussions / C#
   

C#

 
AnswerRe: getting hyperlink Pin
Robert Rohde20-Apr-06 22:46
Robert Rohde20-Apr-06 22:46 
QuestionUsing PropertyGrid and Collection Editor Pin
JuanAlbertoMD20-Apr-06 11:29
JuanAlbertoMD20-Apr-06 11:29 
AnswerRe: Using PropertyGrid and Collection Editor Pin
Robert Rohde20-Apr-06 22:50
Robert Rohde20-Apr-06 22:50 
QuestionBoolean Optimization Pin
Drew McGhie20-Apr-06 11:27
Drew McGhie20-Apr-06 11:27 
AnswerRe: Boolean Optimization Pin
User 665820-Apr-06 11:51
User 665820-Apr-06 11:51 
AnswerRe: Boolean Optimization Pin
Guffa20-Apr-06 11:58
Guffa20-Apr-06 11:58 
QuestionThreads and ProgressBar Pin
achrafus20-Apr-06 11:01
achrafus20-Apr-06 11:01 
AnswerRe: Threads and ProgressBar Pin
Ed.Poore20-Apr-06 12:13
Ed.Poore20-Apr-06 12:13 
AnswerRe: Threads and ProgressBar Pin
mikanu20-Apr-06 18:03
mikanu20-Apr-06 18:03 
Questionhow set a orginate time of Unix timpstamp value?? Pin
Real Coder20-Apr-06 10:05
Real Coder20-Apr-06 10:05 
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 

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.