コード例 #1
0
void QWindowsBackingStore::resize(const QSize &sizeDip, const QRegion &regionDip)
{
    const QSize size = sizeDip * QWindowsScaling::factor();
    if (m_image.isNull() || m_image->image().size() != size) {
#ifndef QT_NO_DEBUG_OUTPUT
        if (QWindowsContext::verbose && lcQpaBackingStore().isDebugEnabled()) {
            qCDebug(lcQpaBackingStore)
                << __FUNCTION__ << ' ' << window() << ' ' << size << ' ' << sizeDip << ' '
                << regionDip << " from: " << (m_image.isNull() ? QSize() : m_image->image().size());
        }
#endif
        const QImage::Format format = window()->format().hasAlpha() ?
            QImage::Format_ARGB32_Premultiplied : QWindowsNativeImage::systemFormat();

        QWindowsNativeImage *oldwni = m_image.data();
        QWindowsNativeImage *newwni = new QWindowsNativeImage(size.width(), size.height(), format);

        if (oldwni && !regionDip.isEmpty()) {
            const QImage &oldimg(oldwni->image());
            QImage &newimg(newwni->image());
            QRegion staticRegion = QWindowsScaling::mapToNative(regionDip);
            staticRegion &= QRect(0, 0, oldimg.width(), oldimg.height());
            staticRegion &= QRect(0, 0, newimg.width(), newimg.height());
            QPainter painter(&newimg);
            painter.setCompositionMode(QPainter::CompositionMode_Source);
            foreach (const QRect &rect, staticRegion.rects())
                painter.drawImage(rect, oldimg, rect);
        }

        if (QWindowsScaling::isActive())
            newwni->setDevicePixelRatio(QWindowsScaling::factor());
        m_image.reset(newwni);
    }
}
コード例 #2
0
void PHIContext2D::setSize( int width, int height )
{
    endPainting();
    QImage newimg( width, height, QImage::Format_ARGB32_Premultiplied );
    newimg.fill( qRgba( 0, 0, 0, 0 ) );
    QPainter p( &newimg );
    p.drawImage( 0, 0, _image );
    p.end();
    _image=newimg;
    scheduleChange();
}
コード例 #3
0
ファイル: diffpng.cpp プロジェクト: Aidoru/openscad
	// shift image by the given number of pixels
	void Shift(int xpix, int ypix)
	{
		RGBAImage newimg( Width, Height, this->Name );
		uint8_t red, green, blue, alpha;
		for (unsigned x = 0; x < Width; x++) {
		for (unsigned y = 0; y < Height; y++) {
                        red = this->Get_Red(     (y+ypix)*Width + (x+xpix) );
			green = this->Get_Green( (y+ypix)*Width + (x+xpix) );
			blue = this->Get_Blue(   (y+ypix)*Width + (x+xpix) );
			alpha = this->Get_Alpha( (y+ypix)*Width + (x+xpix) );
			newimg.Set( red, green, blue, alpha, y*Width+x );
		}
		}
		Data.clear();
		Data.resize( newimg.Data.size() );
		for (unsigned i=0;i<newimg.Data.size();i++) {
			Data[i] = newimg.Data[i];
		}
	}
コード例 #4
0
ファイル: diffpng.cpp プロジェクト: Aidoru/openscad
	// make the image half its original width & height (1/4 the area).
	// this will slightly blur the image.
	// the result somewhat resembles antialiasing.
	void DownSample()
	{
		unsigned int redsum,greensum,bluesum,alphasum;
		unsigned int redavg,greenavg,blueavg,alphaavg;
		uint8_t red, green, blue, alpha;
		unsigned oldwidth = Width;
		//unsigned oldheight = Height;
		unsigned newwidth = Width/2;
		unsigned newheight = Height/2;
		RGBAImage newimg( newwidth, newheight, this->Name );
		for (unsigned x = 0; x < newwidth; x++) {
		for (unsigned y = 0; y < newheight; y++) {
			redsum=greensum=bluesum=alphasum=0;
			redavg=greenavg=blueavg=alphaavg=0;
			for (int i=-1;i<=1;i++) {
			for (int j=-1;j<=1;j++) {
	                        red = this->Get_Red(     (y*2+i)*oldwidth + (x*2+j) );
				green = this->Get_Green( (y*2+i)*oldwidth + (x*2+j) );
				blue = this->Get_Blue(   (y*2+i)*oldwidth + (x*2+j) );
				alpha = this->Get_Alpha( (y*2+i)*oldwidth + (x*2+j) );
				redsum += red;
				greensum += green;
				bluesum += blue;
				alphasum += alpha;
			}
			}
			redavg = redsum / 9;
			greenavg = greensum / 9;
			blueavg = bluesum / 9;
			alphaavg = alphasum / 9;
			newimg.Set( redavg, greenavg, blueavg, alphaavg, y*newwidth+x );
		}
		}
		Width = newwidth;
		Height = newheight;
		Data.clear();
		Data.resize( newimg.Data.size() );
		for (unsigned i=0;i<newimg.Data.size();i++) {
			Data[i] = newimg.Data[i];
		}
	}
コード例 #5
0
ファイル: aprstat.c プロジェクト: SQ6NTI/dxlAPRS
extern void aprstat_wxgraph(maptool_pIMAGE * img, aprsdecode_pOPHIST op,
                unsigned long stime, unsigned short * what,
                struct aprstat_LASTVAL * lastval)
{
   aprsdecode_pFRAMEHIST fr;
   unsigned long Maxx;
   unsigned long step;
   unsigned long xt;
   unsigned long xi;
   float XStep;
   float yax1;
   float yax0;
   float vh;
   struct WX min0;
   struct WX max0;
   char hh[256];
   char h[256];
   char s[256];
   struct aprsdecode_DAT dat;
   float temp[1440];
   float hyg[1440];
   float baro[1440];
   float winds[1440];
   float windd[1440];
   float gust[1440];
   float rain1[1440];
   float rain24[1440];
   float rain0[1440];
   float lumi[1440];
   unsigned short have;
   char dirvalid;
   struct WX * anonym;
   if (op==0 || op->frames==0) {
      /*OR (op^.lastinftyp<100)*/
      return;
   }
   Maxx = dynmaxx(8UL, 320UL, 720UL);
   XStep = X2C_DIVR((float)Maxx,1440.0f);
   *img = 0;
   for (xi = 0UL; xi<=1439UL; xi++) {
      temp[xi] = (-1.E+4f);
      hyg[xi] = (-1.E+4f);
      baro[xi] = (-1.E+4f);
      winds[xi] = (-1.E+4f);
      windd[xi] = (-1.E+4f);
      gust[xi] = (-1.E+4f);
      rain1[xi] = (-1.E+4f);
      rain24[xi] = (-1.E+4f);
      rain0[xi] = (-1.E+4f);
      lumi[xi] = (-1.E+4f);
   } /* end for */
   { /* with */
      struct WX * anonym = &max0;
      anonym->temp = (-1.E+4f);
      anonym->hyg = (-1.E+4f);
      anonym->baro = (-1.E+4f);
      anonym->wind = (-1.E+4f);
      anonym->rain = (-1.E+4f);
      anonym->lumi = (-1.E+4f);
      anonym->siev = (-1.E+4f);
   }
   dirvalid = 0;
   min0.temp = X2C_max_real;
   min0.baro = X2C_max_real;
   memset((char *)lastval,(char)0,sizeof(struct aprstat_LASTVAL));
   fr = op->frames;
   do {
      if (((fr->time0>stime-86400UL && fr->time0<=stime)
                && aprsdecode_Decode(fr->vardat->raw, 500ul,
                &dat)>=0L) && dat.sym=='_') {
         xt = aprsdecode_trunc((float)(fr->time0-(stime-86400UL))
                *1.6666666666667E-2f);
         if (xt>=1440UL) xt = 1439UL;
         vh = X2C_DIVR(dat.wx.temp-32.0f,1.8f);
         if (vh>=(-99.0f) && vh<=99.0f) {
            temp[xt] = vh;
            if (vh>max0.temp) max0.temp = vh;
            if (vh<min0.temp) min0.temp = vh;
            lastval->temp = vh;
         }
         if (dat.wx.hygro>=0.0f && dat.wx.hygro<=100.0f) {
            hyg[xt] = dat.wx.hygro;
            if (dat.wx.hygro>max0.hyg) max0.hyg = dat.wx.hygro;
            lastval->hyg = dat.wx.hygro;
         }
         vh = dat.wx.baro*0.1f;
         if (vh>=900.0f && vh<=1100.0f) {
            baro[xt] = vh;
            if (vh>max0.baro) max0.baro = vh;
            if (vh<min0.baro) min0.baro = vh;
            lastval->baro = vh;
         }
         vh = dat.wx.rain24*0.254f;
         if (vh>=0.0f && vh<300.0f) {
            rain24[xt] = vh;
            if (vh>max0.rain) max0.rain = vh;
            lastval->rain24 = vh;
         }
         vh = dat.wx.raintoday*0.254f;
         if (vh>=0.0f && vh<300.0f) {
            rain0[xt] = vh;
            if (vh>max0.rain) max0.rain = vh;
         }
         vh = dat.wx.rain1*0.254f;
         if (vh>=0.0f && vh<300.0f) {
            rain1[xt] = vh;
            if (vh>max0.rain) max0.rain = vh;
            lastval->rain = vh;
         }
         if (dat.wx.lum>=0.0f && dat.wx.lum<=2000.0f) {
            lumi[xt] = dat.wx.lum;
            if (dat.wx.lum>max0.lumi) max0.lumi = dat.wx.lum;
            lastval->lumi = dat.wx.lum;
         }
         if (dat.wx.sievert>=0.0f && dat.wx.sievert<1000.0f) {
            /*        siev[xt]:=dat.wx.sievert; */
            if (dat.wx.sievert>max0.siev) max0.siev = dat.wx.sievert;
            lastval->siev = dat.wx.sievert;
         }
         if (dat.course>0UL && dat.course<=360UL) {
            lastval->winddir = (float)(dat.course%360UL);
            windd[xt] = lastval->winddir;
            dirvalid = 1;
         }
         vh = (float)dat.speed*1.609f;
         if (vh>=0.0f && vh<=1000.0f) {
            winds[xt] = vh;
            lastval->winds = vh;
            if (vh>max0.wind) max0.wind = vh;
         }
         vh = dat.wx.gust*1.609f;
         if (vh>=0.0f && vh<=1000.0f) {
            gust[xt] = vh;
            lastval->gust = vh;
            if (vh>max0.wind) max0.wind = vh;
         }
      }
      fr = fr->next;
   } while (fr);
   aprstext_DateLocToStr(stime, h, 256ul);
   aprsstr_Append(h, 256ul, " ", 2ul);
   aprsstr_Append(h, 256ul, op->call, 9ul);
   have = 0U;
   if (max0.temp!=(-1.E+4f)) {
      have |= 0x1U;
      if ((0x1U & *what)) {
         if (!newimg(Maxx, img)) return;
         scale(temp, 1440ul, min0.temp, max0.temp, 120.0f, 10.0f, &yax0,
                &yax1, &step);
         aprsstr_FixToStr(lastval->temp, 2UL, s, 256ul);
         aprsstr_Append(s, 256ul, "\177C ", 4ul);
         aprsstr_Append(s, 256ul, h, 256ul);
         paper(img, yax0, yax1, step, 8UL, Maxx, 120UL, s, 256ul);
         timeline(stime, img, Maxx);
         dots(XStep, img, temp, 1440ul, 1, 200UL, 700UL, 40UL);
      }
   }
   if (max0.baro!=(-1.E+4f)) {
      have |= 0x2U;
      if ((0x2U & *what)) {
         if (!newimg(Maxx, img)) return;
         scale(baro, 1440ul, min0.baro, max0.baro, 120.0f, 2.0f, &yax0,
                &yax1, &step);
         aprsstr_FixToStr(lastval->baro, 2UL, s, 256ul);
         aprsstr_Append(s, 256ul, "hPa ", 5ul);
         aprsstr_Append(s, 256ul, h, 256ul);
         paper(img, yax0, yax1, step, 8UL, Maxx, 120UL, s, 256ul);
         timeline(stime, img, Maxx);
         dots(XStep, img, baro, 1440ul, 1, 500UL, 400UL, 500UL);
      }
   }
   if (max0.wind!=(-1.E+4f) && max0.wind>0.0f) {
      have |= 0x8U;
      if ((0x8U & *what)) {
         if (!newimg(Maxx, img)) return;
         scale(winds, 1440ul, (-1.E+4f), max0.wind, 120.0f, 20.0f, &yax0,
                &yax1, &step);
         scale(gust, 1440ul, (-1.E+4f), max0.wind, 120.0f, 20.0f, &yax0,
                &yax1, &step);
         s[0U] = 0;
         if (lastval->winds!=0.0f || lastval->gust==0.0f) {
            aprsstr_FixToStr(lastval->winds, 2UL, hh, 256ul);
            aprsstr_Append(hh, 256ul, "km/h Wind  ", 12ul);
            aprsstr_Append(s, 256ul, hh, 256ul);
         }
         if (lastval->gust!=0.0f) {
            aprsstr_FixToStr(lastval->gust, 2UL, hh, 256ul);
            aprsstr_Append(hh, 256ul, "km/h Gust  ", 12ul);
            aprsstr_Append(s, 256ul, hh, 256ul);
         }
         aprsstr_Append(s, 256ul, h, 256ul);
         paper(img, yax0, yax1, step, 8UL, Maxx, 120UL, s, 256ul);
         timeline(stime, img, Maxx);
         dots(XStep, img, winds, 1440ul, 1, 100UL, 500UL, 700UL);
         dots(XStep, img, gust, 1440ul, 1, 600UL, 100UL, 0UL);
      }
      if (dirvalid) {
         have |= 0x10U;
         if ((0x10U & *what)) {
            if (!newimg(Maxx, img)) return;
            scale(windd, 1440ul, (-1.E+4f), 360.0f, 120.0f, 365.0f, &yax0,
                &yax1, &step);
            aprsstr_FixToStr(lastval->winddir, 0UL, s, 256ul);
            aprsstr_Append(s, 256ul, "deg Wind Direction ", 20ul);
            aprsstr_Append(s, 256ul, h, 256ul);
            paper(img, yax0, yax1, 90UL, 8UL, Maxx, 120UL, s, 256ul);
            timeline(stime, img, Maxx);
            dots(XStep, img, windd, 1440ul, 0, 200UL, 700UL, 700UL);
         }
      }
   }
   if (max0.hyg!=(-1.E+4f)) {
      have |= 0x4U;
      if ((0x4U & *what)) {
         if (!newimg(Maxx, img)) return;
         scale(hyg, 1440ul, (-1.E+4f), 100.0f, 120.0f, 101.0f, &yax0, &yax1,
                &step);
         aprsstr_FixToStr(lastval->hyg, 0UL, s, 256ul);
         aprsstr_Append(s, 256ul, "% Humidty ", 11ul);
         aprsstr_Append(s, 256ul, h, 256ul);
         paper(img, yax0, yax1, step, 8UL, Maxx, 120UL, s, 256ul);
         timeline(stime, img, Maxx);
         dots(XStep, img, hyg, 1440ul, 1, 0UL, 500UL, 700UL);
      }
   }
   if (max0.lumi!=(-1.E+4f)) {
      have |= 0x40U;
      if ((0x40U & *what)) {
         if (!newimg(Maxx, img)) return;
         scale(lumi, 1440ul, (-1.E+4f), max0.lumi, 120.0f, 50.0f, &yax0,
                &yax1, &step);
         aprsstr_FixToStr(lastval->lumi, 0UL, s, 256ul);
         aprsstr_Append(s, 256ul, "W/m^2 Luminosity ", 18ul);
         aprsstr_Append(s, 256ul, h, 256ul);
         paper(img, yax0, yax1, step, 8UL, Maxx, 120UL, s, 256ul);
         timeline(stime, img, Maxx);
         dots(XStep, img, lumi, 1440ul, 1, 600UL, 600UL, 0UL);
      }
   }
   if (max0.rain!=(-1.E+4f)) {
      have |= 0x20U;
      if ((0x20U & *what)) {
         if (!newimg(Maxx, img)) return;
         scale(rain1, 1440ul, (-1.E+4f), max0.rain, 120.0f, 5.0f, &yax0,
                &yax1, &step);
         scale(rain24, 1440ul, (-1.E+4f), max0.rain, 120.0f, 5.0f, &yax0,
                &yax1, &step);
         scale(rain0, 1440ul, (-1.E+4f), max0.rain, 120.0f, 5.0f, &yax0,
                &yax1, &step);
         aprsstr_FixToStr(lastval->rain, 2UL, s, 256ul);
         aprsstr_Append(s, 256ul, "mm Rain ", 9ul);
         aprsstr_Append(s, 256ul, h, 256ul);
         paper(img, yax0, yax1, step, 8UL, Maxx, 120UL, s, 256ul);
         timeline(stime, img, Maxx);
         dots(XStep, img, rain1, 1440ul, 1, 500UL, 100UL, 0UL);
         dots(XStep, img, rain24, 1440ul, 1, 50UL, 600UL, 50UL);
         dots(XStep, img, rain0, 1440ul, 1, 100UL, 100UL, 700UL);
      }
   }
   if (max0.siev>0.0f) have |= 0x400U;
   *what = have;
/*
  IF img<>NIL THEN DISPOSE(img) END;
*/
} /* end wxgraph() */