Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3949714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:31:34+00:00 2026-05-20T01:31:34+00:00

I am trying to use the image GD library to draw lines using an

  • 0

I am trying to use the image GD library to draw lines using an XOR filter. I have not been able to find an easy way to do this so a line being drawn “flips” white to black and vice-versus. Any solutions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:31:35+00:00Added an answer on May 20, 2026 at 1:31 am

    I’m pretty sure that it’s not possible to draw the XOR line with built-in imageline PHP function. Though you can draw it yourself with imagesetpixel and custom line drawing algorithm. For example something like this can work (Bresenham Line Algorythm for PHP):

    function line($im,$x1,$y1,$x2,$y2) {
    
    $deltax=abs($x2-$x1);
    $deltay=abs($y2-$y1);
    
    if ($deltax>$deltay) {
     $numpixels=$deltax+1;
     $d=(2*$deltay)-$deltax;
     $dinc1=$deltay << 1; $dinc2=($deltay-$deltax) << 1;
     $xinc1=1; $xinc2=1;
     $yinc1=0; $yinc2=1;
    } else {
     $numpixels=$deltay+1;
     $d=(2*$deltax)-$deltay;
     $dinc1=$deltax << 1; $dinc2=($deltax-$deltay)<<1;
     $xinc1=0; $xinc2=1;
     $yinc1=1; $yinc2=1;
    }
    
    if ($x1>$x2) {
     $xinc1=-$xinc1;
     $xinc2=-$xinc2;
    }
    
    if ($y1>$y2) {
     $yinc1=-$yinc1;
     $yinc2=-$yinc2;
    }
    $x=$x1;
    $y=$y1;
    
    for ($i=0;$i<$numpixels;$i++) {
    
     $color_current = imagecolorat ( $im, $x, $y );
     $r = ($color_current >> 16) & 0xFF;
     $g = ($color_current >> 8) & 0xFF;
     $b = $color_current & 0xFF;
     $color = imagecolorallocate($im, 255 - $r, 255 - $g, 255 - $b);
    
     imagesetpixel($im,$x,$y,$color);
    
     if ($d<0) {
      $d+=$dinc1;
      $x+=$xinc1;
      $y+=$yinc1;
     } else {
      $d+=$dinc2;
      $x+=$xinc2;
      $y+=$yinc2;
     }
    }
        return ;
    }
    

    Function perfectly works for images, created from files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use Pixastic JavaScript library for image manipulation in Windows 8
I am trying to use GDI+ to draw text onto an image, however, I
I am trying to use sorl-thumbnail to provide image thumbnails. I have followed the
I'm trying to figure out which image management library to use on django. What
I'm learning to use SIMD capabilities by re-writing my personal image processing library using
I am trying ti use carrierWave. I have installed imagemagic using homebrew and both
I'm trying to use the .net API library to get a single image by
I'm trying to do some image processing on iPhone. I'm using http://developer.apple.com/library/ios/#qa/qa2010/qa1702.html to capture
When trying to use convert(1), I get the following error: dyld: Library not loaded:
I'm trying to create an image with the php libgd library and use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.