Beispiel #1
0
FUNCTION int Q43R(obj user, int newType)
{
  int Q5NC = 0x00;
  if(Q50G(user))
  {
    if(newType >= 0x00)
    {
      if(isRiding(user))
      {
        int Q52Q = unRide(user);
      }
      if(!(hasObjVar(Q62D, "oldBodyType")))
      {
        setObjVar(Q62D, "oldBodyType", getObjType(Q62D));
      }
      if(!(hasObjVar(Q62D, "oldHue")))
      {
        setObjVar(Q62D, "oldHue", getHue(Q62D));
      }
      setType(user, newType);
      setHue(user, 0x00);
      int Q4NC = (getSkillLevel(user, 0x19) / 0x05) * 0x05;
      if(isScroll())
      {
        Q4NC = 0x3C;
      }
      Q4MU(user, Q4NC);
      Q5NC = 0x01;
    }
  }
  Q5UQ(this);
  return(Q5NC);
}
	// Re-apply the changes in selection, hue, saturation and luminosity on a fresh palette
	void redraw()
	{
		pal_preview->setPalette(palette);
		pal_preview->getPalette().shift(getHue(),
		                                pal_preview->getSelectionStart(), pal_preview->getSelectionEnd());
		pal_preview->getPalette().saturate(getSat(),
		                                   pal_preview->getSelectionStart(), pal_preview->getSelectionEnd());
		pal_preview->getPalette().illuminate(getLum(),
		                                     pal_preview->getSelectionStart(), pal_preview->getSelectionEnd());
		pal_preview->draw();
	}
Beispiel #3
0
float VideoInput::setHue(float hue)
{
	//HERE;
	if ( hue > 1 )
		hue = 1;
	else
	if ( hue < 0 )
		hue = 0;
	m_hue = hue;
	return getHue();
}
Beispiel #4
0
FUNCTION void Q5VC(obj attacker)
{
  obj n = createGlobalNPCAtSpecificLoc(0x0232, getLocation(this));
  setHue(n, getHue(this));
  int Q4XB = getCurHP(this);
  Q4XB = Q4XB / 0x02;
  setCurHP(n, Q4XB);
  setCurHP(this, Q4XB);
  attack(n, attacker);
  sfx(getLocation(this), random(0x01C8, 0x01CC), 0x00);
  bark(n, "*The slime splits when struck!*");
  return;
}
Beispiel #5
0
TRIGGER( use )(obj user)
{
  int x = getHue(this);
  if(x < 0x0960)
  {
    x = 0x0960;
  }
  x = x + 0x01;
  if(x > 0x097D)
  {
    x = 0x0961;
  }
  setHue(this, x);
  string Q4XU = x;
  bark(this, Q4XU);
  return(0x01);
}
Beispiel #6
0
void Cr2Decoder::interpolate_422_new(int w, int h, int start_h , int end_h) {
  // Last pixel should not be interpolated
  w--;

  // Current line
  ushort16* c_line;
  const int hue = -getHue() + 16384;

  for (int y = start_h; y < end_h; y++) {
    c_line = (ushort16*)mRaw->getData(0, y);
    int r, g, b;
    int off = 0;
    for (int x = 0; x < w; x++) {
      int Y = c_line[off];
      int Cb = c_line[off+1] - hue;
      int Cr = c_line[off+2] - hue;
      YUV_TO_RGB(Y, Cb, Cr);
      STORE_RGB(c_line, off, off + 1, off + 2);
      off += 3;

      Y = c_line[off];
      int Cb2 = (Cb + c_line[off+1+3] - hue) >> 1;
      int Cr2 = (Cr + c_line[off+2+3] - hue) >> 1;
      YUV_TO_RGB(Y, Cb2, Cr2);
      STORE_RGB(c_line, off, off + 1, off + 2);
      off += 3;
    }
    // Last two pixels
    int Y = c_line[off];
    int Cb = c_line[off+1] - 16384;
    int Cr = c_line[off+2] - 16384;
    YUV_TO_RGB(Y, Cb, Cr);
    STORE_RGB(c_line, off, off + 1, off + 2);

    Y = c_line[off+3];
    YUV_TO_RGB(Y, Cb, Cr);
    STORE_RGB(c_line, off + 3, off + 4, off + 5);
  }
}
Beispiel #7
0
void KisColorSelector::mouseReleaseEvent(QMouseEvent* /*event*/)
{
    if (!m_mouseMoved && m_clickedRing >= 0) {
        Radian angle = std::atan2(m_clickPos.x(), m_clickPos.y()) - RAD_90;
        
        m_selectedRing  = m_clickedRing;
        m_selectedPiece = getHueIndex(angle, m_colorRings[m_clickedRing].getShift());
        
        if (getNumPieces() > 1)
            m_selectedColor.setH(getHue(m_selectedPiece, m_colorRings[m_clickedRing].getShift()));
        else
            m_selectedColor.setH(angle.scaled(0.0f, 1.0f));
        
        m_selectedColor.setS(getSaturation(m_selectedRing));
        m_selectedColor.setX(getLight(m_light, m_selectedColor.getH(), m_relativeLight));
        
        setSelectedColor(m_selectedColor, !(m_pressedButtons & Qt::RightButton));
    }
    else if (m_mouseMoved)
        setSelectedColor(m_selectedColor, m_selectedColorIsFgColor);
    
    m_clickedRing = -1;
    update();
}
Beispiel #8
0
BOOLEAN setupDevice(Device device) {
   BOOLEAN change;
   fprintf(stdout, "- Seting up device %p\n", device);


   /* check (again) for a valid device */
   if (!(device->vcapability.type & VID_TYPE_CAPTURE)) {
      fprintf(stdout, "    * The device can't capture video\n");
      return FALSE;
   }

   if (device->vcapability.channels == 0) {
      fprintf(stdout, "    * The device hasn't inputs\n");
      return FALSE;
   }


   /* ---------------------------------------------------------------------- */
   /* let's try to change the capture width & height */
   change = FALSE;
   if (EINTR_RETRY(xioctl(device->fd, VIDIOCGWIN, &device->vwindow)) < 0) {
      perror("VIDIOCGWIN1");
      return FALSE;
   }

   if (device->desiredWidth && (device->vwindow.width != device->desiredWidth)) {
     fprintf(stdout, "    - Changing the width from %d to %d\n", device->vwindow.width, device->desiredWidth);

     device->vwindow.width = device->desiredWidth;
     change = TRUE;
   }
   if (device->desiredHeight && (device->vwindow.height != device->desiredHeight)) {
     fprintf(stdout, "    - Changing the height from %d to %d\n", device->vwindow.height, device->desiredHeight);

     device->vwindow.height = device->desiredHeight;
     change = TRUE;
   }

   if (change) {
      if (EINTR_RETRY(xioctl(device->fd, VIDIOCSWIN, &device->vwindow)) < 0) {
         perror("VIDIOCGWIN2");
         return FALSE;
      }

      if (EINTR_RETRY(xioctl(device->fd, VIDIOCGWIN, &device->vwindow)) < 0) {
         perror("VIDIOCGWIN3");
         return FALSE;
      }
      if (device->desiredWidth != device->vwindow.width) {
         fprintf(stdout,
                 "    * The device can't change the capture width (now=%d)\n",
                 device->vwindow.width);
         return FALSE;
      }
      if (device->desiredHeight != device->vwindow.height) {
         fprintf(stdout,
                 "    * The device can't change the capture height (now=%d)\n",
                 device->vwindow.height);
         return FALSE;
      }

   }

   fprintf(stdout,
           "    - Extent=%d@%d\n",
           device->vwindow.width,
           device->vwindow.height);

   if (EINTR_RETRY(xioctl(device->fd, VIDIOCGPICT, &device->vpicture)) < 0) {
      perror("VIDIOCGPICT");
      return FALSE;
   }

   fprintf(stdout,
           "    - Brightness=%d, Contrast=%d, Saturation=%d, Hue=%d\n",
           getBrightness(device),
           getContrast(device),
           getSaturation(device),
           getHue(device));
   /* ---------------------------------------------------------------------- */


   /* ---------------------------------------------------------------------- */
   if (!setupPalette(device)) {
      return FALSE;
   }
   /* ---------------------------------------------------------------------- */


   device->imageSize = (int) device->vwindow.width * device->vwindow.height * (paletteBytesPerPixel(device->vpicture.palette));
   device->buffer24  = (char*) malloc(device->vwindow.width * device->vwindow.height * 3);

   if (device->forceRead) {
      fprintf(stdout, "    - Capturing using (forced) read()\n");
      if (!switchToRead(device)) {
         return FALSE;
      }
   }
   else {
      setupMMap(device);

      if (device->usingMMap) {
         fprintf(stdout, "    - Capturing using mmap()\n");
         if (!startCaptureInBuffers(device)) {
            fprintf(stdout, "    * Falling back to read()\n");
            if (!switchToRead(device)) {
               return FALSE;
            }
         }
      }
      else {
         fprintf(stdout, "    - Capturing using read()\n");
         if (!switchToRead(device)) {
            return FALSE;
         }
      }
   }

   return TRUE;
}
int GStreamerPlayer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 13)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 13;
    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
        if (_id < 13)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 13;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = getBrightness(); break;
        case 1: *reinterpret_cast< int*>(_v) = getContrast(); break;
        case 2: *reinterpret_cast< int*>(_v) = getHue(); break;
        case 3: *reinterpret_cast< int*>(_v) = getSaturation(); break;
        case 4: *reinterpret_cast< bool*>(_v) = getPlaying(); break;
        case 5: *reinterpret_cast< bool*>(_v) = getPaused(); break;
        case 6: *reinterpret_cast< bool*>(_v) = getStopped(); break;
        default: break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setBrightness(*reinterpret_cast< int*>(_v)); break;
        case 1: setContrast(*reinterpret_cast< int*>(_v)); break;
        case 2: setHue(*reinterpret_cast< int*>(_v)); break;
        case 3: setSaturation(*reinterpret_cast< int*>(_v)); break;
        case 4: setPlaying(*reinterpret_cast< bool*>(_v)); break;
        case 5: setPaused(*reinterpret_cast< bool*>(_v)); break;
        case 6: setStopped(*reinterpret_cast< bool*>(_v)); break;
        default: break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    } else if (_c == QMetaObject::RegisterPropertyMetaType) {
        if (_id < 7)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #10
0
	// Events
	void onHueChanged(wxCommandEvent& e)
	{
		redraw();
		label_hue->SetLabel(S_FMT("%1.3f", getHue()));
	}
bool parseHueLightInfo(HueLightInfo currentInfo, aJsonObject *parsedRoot, HueLightInfo *newInfo) {
  *newInfo = currentInfo;
  aJsonObject* onState = aJson.getObjectItem(parsedRoot, "on");
  if (onState) {
    newInfo->on = onState->valuebool;
  }

  // pull brightness
  aJsonObject* briState = aJson.getObjectItem(parsedRoot, "bri");
  if (briState) {
    newInfo->brightness = briState->valueint;
  }

  // pull effect
  aJsonObject* effectState = aJson.getObjectItem(parsedRoot, "effect");
  if (effectState) {
    const char *effect = effectState->valuestring;
    if (!strcmp(effect, "colorloop")) {
      newInfo->effect = EFFECT_COLORLOOP;
    } else {
      newInfo->effect = EFFECT_NONE;
    }
  }
  // pull alert
  aJsonObject* alertState = aJson.getObjectItem(parsedRoot, "alert");
  if (alertState) {
    const char *alert = alertState->valuestring;
    if (!strcmp(alert, "select")) {
      newInfo->alert = ALERT_SELECT;
    } else if (!strcmp(alert, "lselect")) {
      newInfo->alert = ALERT_LSELECT;
    } else {
      newInfo->alert = ALERT_NONE;
    }
  }

  aJsonObject* hueState = aJson.getObjectItem(parsedRoot, "hue");
  aJsonObject* satState = aJson.getObjectItem(parsedRoot, "sat");
  aJsonObject* ctState = aJson.getObjectItem(parsedRoot, "ct");
  aJsonObject* xyState = aJson.getObjectItem(parsedRoot, "xy");
  if (xyState) {
    aJsonObject* elem0 = aJson.getArrayItem(xyState, 0);
    aJsonObject* elem1 = aJson.getArrayItem(xyState, 1);
    if (!elem0 || !elem1) {
      sendError(5, "/api/api/lights/?/state", "xy color coordinates incomplete");
      return false;
    }
    HsbColor hsb = getXYtoRGB(elem0->valuefloat, elem1->valuefloat, newInfo->brightness);
    newInfo->hue = getHue(hsb);
    newInfo->saturation = getSaturation(hsb);
  } else if (ctState) {
    int mirek = ctState->valueint;
    if (mirek > 500 || mirek < 153) {
      sendError(7, "/api/api/lights/?/state", "Invalid vaule for color temperature");
      return false;
    }

    HsbColor hsb = getMirektoRGB(mirek);
    newInfo->hue = getHue(hsb);
    newInfo->saturation = getSaturation(hsb);
  } else if (hueState || satState) {
    if (hueState) newInfo->hue = hueState->valueint;
    if (satState) newInfo->saturation = satState->valueint;
  }
  return true;
}
Beispiel #12
0
void HSIColor::getHSI(float *HSI) {
  HSI[0] = getHue();
  HSI[1] = getSaturation();
  HSI[2] = getIntensity();
}
Beispiel #13
0
// Note: Not thread safe, since it writes inplace.
void Cr2Decoder::interpolate_420_new(int w, int h, int start_h , int end_h) {
  // Last pixel should not be interpolated
  w--;

  bool atLastLine = FALSE;

  if (end_h == h) {
    end_h--;
    atLastLine = TRUE;
  }

  // Current line
  ushort16* c_line;
  // Next line
  ushort16* n_line;
  // Next line again
  ushort16* nn_line;
  const int hue = -getHue() + 16384;

  int off;
  int r, g, b;

  for (int y = start_h; y < end_h; y++) {
    c_line = (ushort16*)mRaw->getData(0, y * 2);
    n_line = (ushort16*)mRaw->getData(0, y * 2 + 1);
    nn_line = (ushort16*)mRaw->getData(0, y * 2 + 2);
    off = 0;
    for (int x = 0; x < w; x++) {
      int Y = c_line[off];
      int Cb = c_line[off+1] - hue;
      int Cr = c_line[off+2] - hue;
      YUV_TO_RGB(Y, Cb, Cr);
      STORE_RGB(c_line, off, off + 1, off + 2);

      Y = c_line[off+3];
      int Cb2 = (Cb + c_line[off+1+6] - hue) >> 1;
      int Cr2 = (Cr + c_line[off+2+6] - hue) >> 1;
      YUV_TO_RGB(Y, Cb2, Cr2);
      STORE_RGB(c_line, off + 3, off + 4, off + 5);

      // Next line
      Y = n_line[off];
      int Cb3 = (Cb + nn_line[off+1] - hue) >> 1;
      int Cr3 = (Cr + nn_line[off+2] - hue) >> 1;
      YUV_TO_RGB(Y, Cb3, Cr3);
      STORE_RGB(n_line, off, off + 1, off + 2);

      Y = n_line[off+3];
      Cb = (Cb + Cb2 + Cb3 + nn_line[off+1+6] - hue) >> 2;  //Left + Above + Right +Below
      Cr = (Cr + Cr2 + Cr3 + nn_line[off+2+6] - hue) >> 2;
      YUV_TO_RGB(Y, Cb, Cr);
      STORE_RGB(n_line, off + 3, off + 4, off + 5);
      off += 6;
    }
    int Y = c_line[off];
    int Cb = c_line[off+1] - hue;
    int Cr = c_line[off+2] - hue;
    YUV_TO_RGB(Y, Cb, Cr);
    STORE_RGB(c_line, off, off + 1, off + 2);

    Y = c_line[off+3];
    YUV_TO_RGB(Y, Cb, Cr);
    STORE_RGB(c_line, off + 3, off + 4, off + 5);

    // Next line
    Y = n_line[off];
    Cb = (Cb + nn_line[off+1] - hue) >> 1;
    Cr = (Cr + nn_line[off+2] - hue) >> 1;
    YUV_TO_RGB(Y, Cb, Cr);
    STORE_RGB(n_line, off, off + 1, off + 2);

    Y = n_line[off+3];
    YUV_TO_RGB(Y, Cb, Cr);
    STORE_RGB(n_line, off + 3, off + 4, off + 5);
  }

  if (atLastLine) {
    c_line = (ushort16*)mRaw->getData(0, end_h * 2);
    n_line = (ushort16*)mRaw->getData(0, end_h * 2 + 1);
    off = 0;

    // Last line
    for (int x = 0; x < w; x++) {
      int Y = c_line[off];
      int Cb = c_line[off+1] - hue;
      int Cr = c_line[off+2] - hue;
      YUV_TO_RGB(Y, Cb, Cr);
      STORE_RGB(c_line, off, off + 1, off + 2);

      Y = c_line[off+3];
      YUV_TO_RGB(Y, Cb, Cr);
      STORE_RGB(c_line, off + 3, off + 4, off + 5);

      // Next line
      Y = n_line[off];
      YUV_TO_RGB(Y, Cb, Cr);
      STORE_RGB(n_line, off, off + 1, off + 2);

      Y = n_line[off+3];
      YUV_TO_RGB(Y, Cb, Cr);
      STORE_RGB(n_line, off + 3, off + 4, off + 5);
      off += 6;
    }
  }
}
Beispiel #14
0
TRIGGER( targetobj )(obj user, obj usedon)
{
  if(usedon == NULL())
  {
    return(0x00);
  }
  if(isEquipped(usedon))
  {
    systemMessage(user, "Can't Dye clothing that is being worn.");
    return(0x00);
  }
  int Q66P = getObjType(usedon);
  int Q61R = getHue(this);
  loc Q66R = loc( getLocation(usedon) );
  switch(Q66P)
  {
  case 0x0DEF:
  case 0x0DF8:
  case 0x0DF9:
  case 0x0E1D:
  case 0x0E1E:
  case 0x0E1F:
  case 0x0E75:
  case 0x0E76:
  case 0x0F95:
  case 0x0F96:
  case 0x0F97:
  case 0x0F98:
  case 0x0F99:
  case 0x0F9A:
  case 0x0F9B:
  case 0x0F9C:
  case 0x0F9C:
  case 0x0FA0:
  case 0x0FA1:
  case 0x101F:
  case 0x13A4:
  case 0x0BD5:
  case 0x0BD6:
  case 0x0BD7:
  case 0x0BD8:
  case 0x0BD9:
  case 0x0BDA:
  case 0x0BDB:
  case 0x0BDC:
  case 0x0BDD:
  case 0x0BDE:
  case 0x1515:
  case 0x1516:
  case 0x1517:
  case 0x1518:
  case 0x152E:
  case 0x152F:
  case 0x1530:
  case 0x1531:
  case 0x1537:
  case 0x1538:
  case 0x1539:
  case 0x153A:
  case 0x153B:
  case 0x153C:
  case 0x153D:
  case 0x153E:
  case 0x153F:
  case 0x1540:
  case 0x1541:
  case 0x1542:
  case 0x1543:
  case 0x1544:
  case 0x170B:
  case 0x170C:
  case 0x170F:
  case 0x1710:
  case 0x1711:
  case 0x1712:
  case 0x1713:
  case 0x1714:
  case 0x1715:
  case 0x1716:
  case 0x1717:
  case 0x1718:
  case 0x1719:
  case 0x171A:
  case 0x171B:
  case 0x171C:
  case 0x175D:
  case 0x175E:
  case 0x175F:
  case 0x1760:
  case 0x1761:
  case 0x1762:
  case 0x1763:
  case 0x1764:
  case 0x1765:
  case 0x1766:
  case 0x1767:
  case 0x1768:
  case 0x1914:
  case 0x1915:
  case 0x1B74:
  case 0x1B75:
  case 0x1EFD:
  case 0x1EFE:
  case 0x1EFF:
  case 0x1F00:
  case 0x1F01:
  case 0x1F02:
  case 0x1F03:
  case 0x1F04:
  case 0x1F7B:
  case 0x1F7C:
  case 0x1F9F:
  case 0x1FA0:
  case 0x1FA1:
  case 0x1FA2:
  case 0x1F7B:
  case 0x1F7C:
  case 0x1FA1:
  case 0x1FA1:
  case 0x1FFD:
  case 0x1FFE:
    sfx(Q66R, 0x023E, 0x00);
    setHue(usedon, Q61R);
    break;
  }
  return(0x00);
}
Beispiel #15
0
void CHSVColor::print(std::ostream &os) const {
  os << "CHSVColor(" << getHue() << ", " << getSaturation() 
     << ", " << getValue() << ")";
}