SeslMagnifyingView

A custom View that displays a magnified portion of a Bitmap, typically used for an eyedropper tool.

This view draws a circular magnified area of a provided screenshot Bitmap. It includes a grid overlay and a central square to indicate the exact pixel being selected. The border of the magnified area and the central square can be customized with different colors and stroke widths.

The magnification is centered around the touch position (mTouchPosX, mTouchPosY) on the original screenshot. The view itself is circular, and the magnified content is clipped to this circular shape.

Key visual elements:

  • Magnified Screenshot: A zoomed-in portion of the mScreenShotBitmap.
  • Grid Lines: A 15x15 grid is drawn over the magnified area to help with alignment and pixel identification.
  • Center Square: A small square at the very center of the magnifier, highlighting the pixel whose color is being picked.
  • Inner Border: A circular border just inside the main magnifier boundary.
  • Color Border: The outermost circular border, whose color can be dynamically updated (mColorBorderColor).

Initialization of paint objects for drawing these elements occurs in the constructor, using dimension resources for stroke widths. The actual drawing logic is handled in the onDraw method.

Usage typically involves:

  1. Providing a Bitmap to mScreenShotBitmap.
  2. Setting the touch coordinates mTouchPosX and mTouchPosY to indicate the center of the desired magnified area.
  3. Optionally, setting mColorBorderColor to change the color of the outer border.
  4. Adding this view to a layout. The view will then automatically draw the magnified region.

Constructors

Link copied to clipboard
constructor(@NonNull context: @NonNull Context)
constructor(@NonNull context: @NonNull Context, @NonNull attributeSet: @NonNull AttributeSet)
constructor(@NonNull context: @NonNull Context, @NonNull attrs: @NonNull AttributeSet, defStyleAttr: Int)

Functions

Link copied to clipboard
fun onDraw(@NonNull canvas: @NonNull Canvas)