ShowHiClipping.vb
  1. ''
  2. '' This code is part of Document Solutions for Imaging demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports System.Collections.Generic
  8. Imports System.Linq
  9. Imports System.Numerics
  10. Imports GrapeCity.Documents.Drawing
  11. Imports GrapeCity.Documents.Text
  12. Imports GrapeCity.Documents.Imaging
  13.  
  14. '' This sample demonstrates how to find and show
  15. '' pixels with blown out highlights.
  16. Public Class ShowHiClipping
  17. Function GenerateImage(
  18. ByVal pixelSize As Size,
  19. ByVal dpi As Single,
  20. ByVal opaque As Boolean,
  21. Optional ByVal sampleParams As String() = Nothing) As GcBitmap
  22.  
  23. Dim bmp = New GcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi)
  24. Using bmpSrc = New GcBitmap(Path.Combine("Resources", "Images", "tudor.jpg"))
  25. '' BitBlt requires the opacity of both images to be the same:
  26. bmpSrc.Opaque = opaque
  27. '' Render source image onto the target bitmap
  28. '' (generally we might want to resize the source image first,
  29. '' but in this case we just know that the source image has
  30. '' the same size as the target, so skip this step):
  31. bmp.BitBlt(bmpSrc, 0, 0)
  32.  
  33. Using g = bmp.CreateGraphics()
  34. For i = 0 To bmp.PixelWidth - 1
  35. For j = 0 To bmp.PixelHeight - 1
  36. Dim px = bmp(i, j)
  37. '' If any of the colors are 0xFF, we change the pixel's color to magenta:
  38. If (px And &HFF) = &HFF Or (px And &HFF00) = &HFF00 Or (px And &HFF0000) = &HFF0000 Then
  39. bmp(i, j) = &HFFFF00FFUI
  40. End If
  41. Next
  42. Next
  43.  
  44. '' Draw the original image in the bottom right corner for reference:
  45. Dim sx = pixelSize.Width / 3, sy = pixelSize.Height / 3
  46. g.DrawImage(bmpSrc, New RectangleF(sx * 2, sy * 2, sx, sy), Nothing, ImageAlign.StretchImage)
  47. End Using
  48. End Using
  49. Return bmp
  50. End Function
  51. End Class
  52.