Recent

Author Topic: [SOLVED] BGRA Pen Modes  (Read 2931 times)

trayres

  • Jr. Member
  • **
  • Posts: 92
[SOLVED] BGRA Pen Modes
« on: February 19, 2017, 09:37:58 am »
Trying to draw a crosshair; usually I'd just set a pen to pmNotXor, and draw it.

However, I don't see a way to set the pen mode to pmNotXor. I can achieve the same thing by accessing the BGRABitmap's Scanline property & fast-direct pixel access, but I didn't see anything on the wiki about pmNotXnor.

I can access the pen mode for the canvas and get pmNotXnor, but then it could lose some speed (plus it would make the code more convoluted to start drawing directly on the canvas - less isolation).

What am I missing?  :D
« Last Edit: February 20, 2017, 08:09:57 am by trayres »

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: BGRA Pen Modes
« Reply #1 on: February 19, 2017, 03:05:38 pm »
You can use dmXor draw mode with usual drawing functions.

To invert pixels, supply the color BGRA(255,255,255,0). That will invert RGB channels and leave alpha channel as it is.

Code: Pascal  [Select][+][-]
  1. bmp.HorizLine(0,bmp.Height div 2,bmp.Width-1, BGRA(255,255,255,0), dmXor);
  2. bmp.VertLine(bmp.Width div 2,0,bmp.Height-1, BGRA(255,255,255,0), dmXor);

Regards
Conscience is the debugger of the mind

trayres

  • Jr. Member
  • **
  • Posts: 92
Re: [SOLVED] BGRA Pen Modes
« Reply #2 on: February 20, 2017, 08:10:11 am »
Thank you, that works a champ!

 

TinyPortal © 2005-2018