Here are the examples of the csharp api class System.Drawing.Image.GetPixelFormatSize(System.Drawing.Imaging.PixelFormat) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
39 Examples
0
1. Example
Project: QuasarRAT
Source File: VideoCaptureDevice.cs
Source File: VideoCaptureDevice.cs
private void OnNewFrame( Bitmap image ) { framesReceived++; bytesReceived += image.Width * image.Height * ( Bitmap.GetPixelFormatSize( image.PixelFormat ) >> 3 ); if ( ( !stopEvent.WaitOne( 0, false ) ) && ( NewFrame != null ) ) NewFrame( this, new NewFrameEventArgs( image ) ); }
0
2. Example
Project: GXTConvert
Source File: PostProcessing.cs
Source File: PostProcessing.cs
private static int GetTilePixelOffset(int t, int x, int y, int width, PixelFormat pixelFormat) { return (GetTilePixelIndex(t, x, y, width) * (Bitmap.GetPixelFormatSize(pixelFormat) / 8)); }
0
3. Example
Project: Zero-K-Infrastructure
Source File: UnitSync.cs
Source File: UnitSync.cs
private Bitmap GetSquareMinimap(string mapName, int mipLevel) { if ((mipLevel < 0) || (mipLevel > MaxMipLevel)) throw new ArgumentOutOfRangeException("mipLevel", string.Format("Mip level must range from 0 to {0}.", MaxMipLevel)); var size = 1024 >> mipLevel; var pointer = NativeMethods.GetMinimap(mapName, mipLevel); const PixelFormat format = PixelFormat.Format16bppRgb565; var pixelFormatSize = Image.GetPixelFormatSize(format) / 8; var stride = size * pixelFormatSize; return new Bitmap(size, size, stride, format, pointer); }
0
4. Example
Project: SeleniumBasic
Source File: Image.cs
Source File: Image.cs
private static unsafe uint ComputeCRC32(Bitmap bitmap) { uint crc32 = uint.MaxValue; Rectangle rect = new Rectangle(System.Drawing.Point.Empty, bitmap.Size); BitmapData data = bitmap.LockBits(rect, ImageLockMode.ReadOnly, bitmap.PixelFormat); int height = bitmap.Height; int stride = data.Stride; int length = (Bitmap.GetPixelFormatSize(bitmap.PixelFormat) / 8) * bitmap.Width; try { byte* ptr = (byte*)data.Scan0; fixed (uint* pTable = Crc32.CRCTABLE) { for (int r = 0; r < height; r++) { for (int i = 0; i < length; i++) { crc32 = pTable[(crc32 ^ ptr[i]) & 0xFF] ^ (crc32 >> 8); } } ptr += stride; } } finally { bitmap.UnlockBits(data); } return crc32 ^ uint.MaxValue; }
0
5. Example
Project: KelpNet
Source File: NdArrayConverter.cs
Source File: NdArrayConverter.cs
public static NdArray Image2NdArray(Bitmap input, bool isNorm = true, bool isToBgrArray = false, Rea/n ..... /n //View Source file for more details /n }
0
6. Example
Project: Image-Processing-Library
Source File: Filter.cs
Source File: Filter.cs
public static Bitmap BlurFast(Bitmap bmp) { Bitmap output = new Bitmap(bmp.Width/n ..... /n //View Source file for more details /n }
0
7. Example
Project: Image-Processing-Library
Source File: Histogram.cs
Source File: Histogram.cs
private void Create(Bitmap bmp) { unsafe { BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); int bytesPerPixel = Image.GetPixelFormatSize(bmp.PixelFormat) / 8; int heightInPixels = bitmapData.Height; int widthInBytes = bitmapData.Width * bytesPerPixel; byte* PtrFirstPixel = (byte*)bitmapData.Scan0; for (int y = 0; y < heightInPixels; y++) { byte* currentLine = PtrFirstPixel + (y * bitmapData.Stride); for (int x = 0; x < widthInBytes; x = x + bytesPerPixel) { int blue = currentLine[x]; int green = currentLine[x + 1]; int red = currentLine[x + 2]; redBucket[red]++; greenBucket[green]++; blueBucket[blue]++; count += 3; } } bmp.UnlockBits(bitmapData); } }
0
8. Example
Project: Image-Processing-Library
Source File: ViewColors.cs
Source File: ViewColors.cs
private void DrawColorRange() { HSV colorHSV = new HSV(0, 1, 1); Col/n ..... /n //View Source file for more details /n }
0
9. Example
Project: Windows-Hacks
Source File: BasicVision.cs
Source File: BasicVision.cs
public static bool FindBitmap(Bitmap needle, Bitmap haystack, out Point location) { /n ..... /n //View Source file for more details /n }
0
10. Example
Project: ClickerHeroes_AutoPlayer
Source File: LockBitmap.cs
Source File: LockBitmap.cs
private void LockBits() { try { // Get width and height of bitmap Width = source.Width; Height = source.Height; // get total locked pixels count int PixelCount = Width * Height; // Create rectangle to lock Rectangle rect = new Rectangle(0, 0, Width, Height); // get source bitmap pixel format size Depth = System.Drawing.Bitmap.GetPixelFormatSize(source.PixelFormat); // Check if bpp (Bits Per Pixel) is 8, 24, or 32 if (Depth != 8 && Depth != 24 && Depth != 32) { throw new ArgumentException("Only 8, 24 and 32 bpp images are supported."); } // Lock bitmap and return bitmap data bitmapData = source.LockBits(rect, ImageLockMode.ReadWrite, source.PixelFormat); // create byte array to copy pixel values int step = Depth / 8; Pixels = new byte[PixelCount * step]; Iptr = bitmapData.Scan0; // Copy data from pointer to array Marshal.Copy(Iptr, Pixels, 0, Pixels.Length); } catch (Exception ex) { throw ex; } }
0
11. Example
Project: Sardauscan
Source File: LockBitmap.cs
Source File: LockBitmap.cs
public void LockBits() { try { // Get width and height of bitmap Width = Source.Width; Height = Source.Height; // get total locked pixels count int PixelCount = Width * Height; // Create rectangle to lock Rectangle rect = new Rectangle(0, 0, Width, Height); // get source bitmap pixel format size Depth = System.Drawing.Bitmap.GetPixelFormatSize(Source.PixelFormat); Components = Depth / 8; // Check if bpp (Bits Per Pixel) is 8, 24, or 32 if (Depth != 8 && Depth != 24 && Depth != 32) { throw new ArgumentException("Only 8, 24 and 32 bpp images are supported."); } // Lock bitmap and return bitmap data bitmapData = Source.LockBits(rect, ImageLockMode.ReadWrite, Source.PixelFormat); // create byte array to copy pixel values int step = Depth / 8; Pixels = new byte[PixelCount * step]; Iptr = bitmapData.Scan0; // Copy data from pointer to array Marshal.Copy(Iptr, Pixels, 0, Pixels.Length); } catch (Exception ex) { throw ex; } }
0
12. Example
Project: QuickLook
Source File: WindowsThumbnailProvider.cs
Source File: WindowsThumbnailProvider.cs
internal static Bitmap GetBitmapFromHBitmap(IntPtr nativeHBitmap) { var bmp = Image.FromHbitmap(nativeHBitmap); if (Image.GetPixelFormatSize(bmp.PixelFormat) < 32) return bmp; return CreateAlphaBitmap(bmp, PixelFormat.Format32bppArgb); }
0
13. Example
Project: Image-Processing-Library
Source File: Effect.cs
Source File: Effect.cs
public static Bitmap Invert(Bitmap bmp) { unsafe { BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); int bytesPerPixel = System.Drawing.Bitmap.GetPixelFormatSize(bmp.PixelFormat) / 8; int heightInPixels = bitmapData.Height; int widthInBytes = bitmapData.Width * bytesPerPixel; byte* PtrFirstPixel = (byte*)bitmapData.Scan0; Parallel.For(0, heightInPixels, y => { byte* currentLine = PtrFirstPixel + (y * bitmapData.Stride); for (int x = 0; x < widthInBytes; x = x + bytesPerPixel) { int oldBlue = currentLine[x]; int oldGreen = currentLine[x + 1]; int oldRed = currentLine[x + 2]; oldBlue = 255 - oldBlue; oldGreen = 255 - oldGreen; oldRed = 255 - oldRed; currentLine[x] = (byte)oldBlue; currentLine[x + 1] = (byte)oldGreen; currentLine[x + 2] = (byte)oldRed; } }); bmp.UnlockBits(bitmapData); } return bmp; }
0
14. Example
Project: Windows-Hacks
Source File: HueShifter.cs
Source File: HueShifter.cs
private static Bitmap Change(Bitmap bitmap, int degrees) { Color colorRGB; /n ..... /n //View Source file for more details /n }
0
15. Example
Project: Windows-Hacks
Source File: MotionDetector.cs
Source File: MotionDetector.cs
private static void DrawDifference(Bitmap bmp, Color color) { // Bitmaps should /n ..... /n //View Source file for more details /n }
0
16. Example
Project: Zero-K-Infrastructure
Source File: UnitSync.cs
Source File: UnitSync.cs
Bitmap GetSquareMinimap(string mapName, int mipLevel) { if (!GetMapHashes().ContainsValue(mapName)) throw new UnitSyncException(string.Format("Map not found ({0}).", mapName)); if (mipLevel < 0 || mipLevel > MaxMipLevel) throw new ArgumentOutOfRangeException("mipLevel", string.Format("Mip level must range from 0 to {0}.", MaxMipLevel)); var size = 1024 >> mipLevel; var pointer = NativeMethods.GetMinimap(mapName, mipLevel); const PixelFormat format = PixelFormat.Format16bppRgb565; var pixelFormatSize = Image.GetPixelFormatSize(format)/8; var stride = size*pixelFormatSize; return new Bitmap(size, size, stride, format, pointer); }
0
17. Example
Project: KelpNet
Source File: NdArrayConverter.cs
Source File: NdArrayConverter.cs
static Bitmap CreateColorImage(Real[] data, int width, int height, bool isNorm, bool isFromBgrArray)/n ..... /n //View Source file for more details /n }
0
18. Example
Project: halcyon
Source File: Oven.cs
Source File: Oven.cs
public static Bitmap ModifyAlphaMask(Bitmap alpha, byte weight, float ramp) { // Create the new modifiable image (our canvas) int width = alpha.Width; int height = alpha.Height; int pixelFormatSize = Image.GetPixelFormatSize(alpha.PixelFormat) / 8; int stride = width * pixelFormatSize; byte[] data = new byte[stride * height]; //GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0); Bitmap modified = new Bitmap(width, height, stride, alpha.PixelFormat, pointer); // Copy the existing alpha mask to the canvas Graphics g = Graphics.FromImage(modified); g.DrawImageUnscaledAndClipped(alpha, new Rectangle(0, 0, width, height)); g.Dispose(); // Modify the canvas based on the input weight and ramp values // TODO: use the ramp // TODO: only bother with the alpha values for (int i = 0; i < data.Length; i++) { if (data[i] < weight) data[i] = 0; } return modified; }
0
19. Example
Project: halcyon
Source File: Oven.cs
Source File: Oven.cs
public static Bitmap ApplyAlphaMask(Bitmap source, Bitmap alpha) { // Create the new modifiable image (our canvas) int width = source.Width; int height = source.Height; if (alpha.Width != width || alpha.Height != height || alpha.PixelFormat != source.PixelFormat) { throw new Exception("Source image and alpha mask formats do not match"); } int pixelFormatSize = Image.GetPixelFormatSize(source.PixelFormat) / 8; int stride = width * pixelFormatSize; byte[] data = new byte[stride * height]; //GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0); Bitmap modified = new Bitmap(width, height, stride, source.PixelFormat, pointer); // Copy the source image to the canvas Graphics g = Graphics.FromImage(modified); g.DrawImageUnscaledAndClipped(source, new Rectangle(0, 0, width, height)); g.Dispose(); // Get access to the pixel data for the alpha mask (probably using lockbits) // Combine the alpha mask alpha bytes in to the canvas return modified; }
0
20. Example
Project: Image-Processing-Library
Source File: Effect.cs
Source File: Effect.cs
public static Bitmap Threshold(Bitmap bmp, int[] T) { unsafe { /n ..... /n //View Source file for more details /n }
0
21. Example
Project: Windows-Hacks
Source File: BasicVision.cs
Source File: BasicVision.cs
public static double CompareByPixels(Bitmap bmp1, Bitmap bmp2) { // Bitmaps shou/n ..... /n //View Source file for more details /n }
0
22. Example
Project: Serenity
Source File: SearchHelper.cs
Source File: SearchHelper.cs
public static Point SearchColor(ref Bitmap screenCapture, Color searchColor, int tolerance = 0) /n ..... /n //View Source file for more details /n }
0
23. Example
Project: VoxelSim
Source File: Oven.cs
Source File: Oven.cs
public static Bitmap ModifyAlphaMask(Bitmap alpha, byte weight, float ramp) { // Create the new modifiable image (our canvas) int width = alpha.Width; int height = alpha.Height; int pixelFormatSize = Image.GetPixelFormatSize(alpha.PixelFormat) / 8; int stride = width * pixelFormatSize; byte[] data = new byte[stride * height]; //GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0); Bitmap modified = new Bitmap(width, height, stride, alpha.PixelFormat, pointer); // Copy the existing alpha mask to the canvas Graphics g = Graphics.FromImage(modified); g.DrawImageUnscaledAndClipped(alpha, new Rectangle(0, 0, width, height)); g.Dispose(); // Modify the canvas based on the input weight and ramp values // TODO: use the ramp // TODO: only bother with the alpha values for (int i = 0; i < data.Length; i++) { if (data[i] < weight) data[i] = 0; } return modified; }
0
24. Example
Project: VoxelSim
Source File: Oven.cs
Source File: Oven.cs
public static Bitmap ApplyAlphaMask(Bitmap source, Bitmap alpha) { // Create the new modifiable image (our canvas) int width = source.Width; int height = source.Height; if (alpha.Width != width || alpha.Height != height || alpha.PixelFormat != source.PixelFormat) { throw new Exception("Source image and alpha mask formats do not match"); } int pixelFormatSize = Image.GetPixelFormatSize(source.PixelFormat) / 8; int stride = width * pixelFormatSize; byte[] data = new byte[stride * height]; //GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0); Bitmap modified = new Bitmap(width, height, stride, source.PixelFormat, pointer); // Copy the source image to the canvas Graphics g = Graphics.FromImage(modified); g.DrawImageUnscaledAndClipped(source, new Rectangle(0, 0, width, height)); g.Dispose(); // Get access to the pixel data for the alpha mask (probably using lockbits) // Combine the alpha mask alpha bytes in to the canvas return modified; }
0
25. Example
Project: GerberTools
Source File: ImageCreator.cs
Source File: ImageCreator.cs
public void LockBits() { try { // Get width and heig/n ..... /n //View Source file for more details /n }
0
26. Example
Project: GXTConvert
Source File: PostProcessing.cs
Source File: PostProcessing.cs
public static byte[] UnswizzleTexture(byte[] pixelData, int width, int height, PixelFormat pixelFormat) { int bytesPerPixel = (Bitmap.GetPixelFormatSize(pixelFormat) / 8); byte[] unswizzled = new byte[pixelData.Length]; for (int i = 0; i < width * height; i++) { int min = width < height ? width : height; int k = (int)Math.Log(min, 2); int x, y; if (height < width) { // tttyxyxyx ? ttttttyyy int j = i >> (2 * k) << (2 * k) | (DecodeMorton2Y(i) & (min - 1)) << k | (DecodeMorton2X(i) & (min - 1)) << 0; x = j / height; y = j % height; } else { // YYYyxyxyx ? YYYyyyttt int j = i >> (2 * k) << (2 * k) | (DecodeMorton2X(i) & (min - 1)) << k | (DecodeMorton2Y(i) & (min - 1)) << 0; x = j % width; y = j / width; } if (y >= height || x >= width) continue; Buffer.BlockCopy(pixelData, i * bytesPerPixel, unswizzled, ((y * width) + x) * bytesPerPixel, bytesPerPixel); } return unswizzled; }
0
27. Example
Project: Kuriimu
Source File: TmxSupport.cs
Source File: TmxSupport.cs
public static Bitmap Convert24(BinaryReaderX br, Header header) { Bitmap bmp = new Bitmap(header.width, header.height, PixelFormat.Format32bppArgb); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); byte[] pixelData = new byte[bmpData.Height * bmpData.Stride]; Marshal.Copy(bmpData.Scan0, pixelData, 0, pixelData.Length); for (int i = 0; i < (bmpData.Width * bmpData.Height) * (Bitmap.GetPixelFormatSize(bmp.PixelFormat) / 8); i += 4) { pixelData[i + 2] = br.ReadByte(); pixelData[i + 1] = br.ReadByte(); pixelData[i + 0] = br.ReadByte(); pixelData[i + 3] = ScaleAlpha(0x80); } Marshal.Copy(pixelData, 0, bmpData.Scan0, pixelData.Length); bmp.UnlockBits(bmpData); return bmp; }
0
28. Example
Project: Kuriimu
Source File: TmxSupport.cs
Source File: TmxSupport.cs
public static Bitmap Convert32(BinaryReaderX br, Header header) { Bitmap bmp = new Bitmap(header.width, header.height, PixelFormat.Format32bppArgb); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); byte[] pixelData = new byte[bmpData.Height * bmpData.Stride]; Marshal.Copy(bmpData.Scan0, pixelData, 0, pixelData.Length); for (int i = 0; i < (bmpData.Width * bmpData.Height) * (Bitmap.GetPixelFormatSize(bmp.PixelFormat) / 8); i += 4) { pixelData[i + 2] = br.ReadByte(); pixelData[i + 1] = br.ReadByte(); pixelData[i + 0] = br.ReadByte(); byte a = br.ReadByte(); pixelData[i + 3] = ScaleAlpha(a); } Marshal.Copy(pixelData, 0, bmpData.Scan0, pixelData.Length); bmp.UnlockBits(bmpData); return bmp; }
0
29. Example
Project: Windows-Hacks
Source File: BasicVision.cs
Source File: BasicVision.cs
public static Bitmap PrintDifference(Bitmap bmp1, Bitmap bmp2, bool printImage) { /n ..... /n //View Source file for more details /n }
0
30. Example
Project: Zero-K-Infrastructure
Source File: UnitSync.cs
Source File: UnitSync.cs
public Bitmap GetMinimap(string mapName, int mipLevel) { if (disposed) { throw new ObjectDisposedException("Unitsync has already been disposed."); } if (!mapName.ToLower().EndsWith(".smf") && !(mapName.ToLower().EndsWith(".sm3"))) { throw new ArgumentException("Map name is invalid, must end with \".smf\" or \".sm3\"."); } if (!GetMapNames().ContainsValue(mapName)) { throw new UnitSyncException(string.Format("Map not found ({0}).", mapName)); } if (mipLevel < 0 || mipLevel > MaxMipLevel) { throw new ArgumentOutOfRangeException( "mipLevel", string.Format("Mip level must range from 0 to {0}.", MaxMipLevel)); } int size = 1024 >> mipLevel; IntPtr pointer = NativeMethods.GetMinimap(mapName, mipLevel); const PixelFormat format = PixelFormat.Format16bppRgb565; int pixelFormatSize = Image.GetPixelFormatSize(format)/8; int stride = size*pixelFormatSize; return new Bitmap(size, size, stride, format, pointer); }
0
31. Example
Project: ImageGlass
Source File: ImageComparator.cs
Source File: ImageComparator.cs
private bool CompareBitmaps(Image left, Image right) { if (object.Equals(left, r/n ..... /n //View Source file for more details /n }
0
32. Example
Project: Kuriimu
Source File: TmxSupport.cs
Source File: TmxSupport.cs
public static Bitmap Convert16(BinaryReaderX br, Header header) { Bitmap bmp = new Bitmap(header.width, header.height, PixelFormat.Format32bppArgb); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); byte[] pixelData = new byte[bmpData.Height * bmpData.Stride]; Marshal.Copy(bmpData.Scan0, pixelData, 0, pixelData.Length); for (int i = 0; i < (bmpData.Width * bmpData.Height) * (Bitmap.GetPixelFormatSize(bmp.PixelFormat) / 8); i += 4) { ushort rgba = br.ReadUInt16(); pixelData[i + 2] = ResampleChannel((rgba >> 0), 5, 8); pixelData[i + 1] = ResampleChannel((rgba >> 5), 5, 8); pixelData[i + 0] = ResampleChannel((rgba >> 10), 5, 8); /* TODO: verify alpha */ pixelData[i + 3] = ScaleAlpha(ResampleChannel((rgba >> 15), 1, 8)); } Marshal.Copy(pixelData, 0, bmpData.Scan0, pixelData.Length); bmp.UnlockBits(bmpData); return bmp; }
0
33. Example
Project: Tibialyzer
Source File: Form1.cs
Source File: Form1.cs
public unsafe Node[,] CreateNodes(Image image, int z, List<Dictionary<Tuple<int, int>, s/n ..... /n //View Source file for more details /n }
0
34. Example
Project: GXTConvert
Source File: TextureBundle.cs
Source File: TextureBundle.cs
public Bitmap CreateTexture(Color[] palette = null) { Bitmap texture = new Bitma/n ..... /n //View Source file for more details /n }
0
35. Example
Project: Rainbow
Source File: WuQuantizerBase.cs
Source File: WuQuantizerBase.cs
private static ColorData BuildHistogram(Bitmap sourceImage, int alphaThreshold, int alphaFader) /n ..... /n //View Source file for more details /n }
0
36. Example
Project: SWYH
Source File: UPnPDevice.cs
Source File: UPnPDevice.cs
private void GetNonRootDeviceXML(IPEndPoint local, XmlTextWriter XDoc) { IDictio/n ..... /n //View Source file for more details /n }
0
37. Example
Project: bdhero
Source File: EuclideanQuantizer.cs
Source File: EuclideanQuantizer.cs
public unsafe Bitmap Convert(Bitmap source, PixelFormat outputFormat) { DateTime/n ..... /n //View Source file for more details /n }
0
38. Example
Project: bdhero
Source File: OctreeQuantizer.cs
Source File: OctreeQuantizer.cs
public unsafe ColorPalette CreatePalette(Bitmap image, int maxColors, int bitsPerPixel) { /n ..... /n //View Source file for more details /n }
0
39. Example
Project: Xploit
Source File: BinaryFromScreen.cs
Source File: BinaryFromScreen.cs
byte[] SearchFor(Bitmap capture, ushort step, ref string extra, ref ushort max, ref uint length, ref/n ..... /n //View Source file for more details /n }