Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
2.50/5 (4 votes)
See more:
i have created an image in c#
but i don't know how to get it's path
how can i get it?

[Moved from OP Comment]
this is my code:
Bitmap sourceImg = new Bitmap("d:\\images\\a.bmp");
          Bitmap destImg = new Bitmap(sourceImg.Width, sourceImg.Height);

          Rectangle dataRect =
          new Rectangle(0, 0, sourceImg.Width, sourceImg.Height);
          BitmapData sourceData = sourceImg.LockBits(dataRect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
          BitmapData destData =
          destImg.LockBits(dataRect, ImageLockMode.WriteOnly,
          PixelFormat.Format32bppArgb);
          IntPtr sourcePtr = sourceData.Scan0;
          IntPtr destPtr = destData.Scan0;
          byte[] buffer = new byte[sourceData.Stride];
          for (int row = 0; row < sourceImg.Height; row++)
          {
                             System.Runtime.InteropServices.Marshal.Copy(    sourcePtr, buffer, 0, sourceData.Stride);

              for (int i = 0; i < buffer.Length; i += 4)
              {
                                      buffer[i + 0] /= 2;
                  buffer[i + 1] /= 2;
                  buffer[i + 2] /= 2;
              }
              System.Runtime.InteropServices.Marshal.Copy(
              buffer, 0, destPtr, destData.Stride);
              sourcePtr = new IntPtr(sourcePtr.ToInt64() + sourceData.Stride);
              destPtr = new IntPtr(destPtr.ToInt64() + destData.Stride);
          }
          sourceImg.UnlockBits(sourceData);
          destImg.UnlockBits(destData);
Posted
Updated 23-Feb-11 11:46am
v3
Comments
Sergey Alexandrovich Kryukov 23-Feb-11 16:07pm    
This is helpless. I also don't know how to get it's path, guess why?
--SA
Steve Wellens 23-Feb-11 16:14pm    
Where did you save it?
Toli Cuturicu 23-Feb-11 17:47pm    
Good joke! (the question was a joke, wasn't it?!)

1 solution

It does not apprear that you have saved your destImg bitmap

destImg.Save(@"d:\images\MyNewBitmap.bmp")
 
Share this answer
 
Comments
Espen Harlinn 25-Feb-11 11:25am    
Well spotted, my 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900