コード例 #1
0
ファイル: main.c プロジェクト: DuinoPilot/ChibiOS-GFX
void mandelbrot(float x1, float y1, float x2, float y2) {
	unsigned int i,j, width, height;
	uint16_t iter;
	color_t color;
	float fwidth, fheight;
	
	float sy = y2 - y1;
	float sx = x2 - x1;
	const int MAX = 512;
	
	width = (unsigned int)gdispGetWidth();
	height = (unsigned int)gdispGetHeight();
	fwidth = width;
	fheight = height;
	
	for(i = 0; i < width; i++) {
		for(j = 0; j < height; j++) {
			float cy = j * sy / fheight + y1;
			float cx = i * sx / fwidth + x1;
			float x=0.0f, y=0.0f, xx=0.0f, yy=0.0f;
			for(iter=0; iter <= MAX && xx+yy<4.0f; iter++) {
				xx = x*x;
				yy = y*y;
				y = 2.0f*x*y + cy;
				x = xx - yy + cx;
			}
			//color = ((iter << 8) | (iter&0xFF));
			color = RGB2COLOR(iter<<7, iter<<4, iter);
			gdispDrawPixel(i, j, color);
		}
	}
}
コード例 #2
0
ファイル: i_video.c プロジェクト: bigzed/uGFX
//
// I_SetPalette
//
void I_SetPalette (byte* palette)
{
    int	i;

    for (i=0 ; i<256 ; i++, palette+=3) {
    	colors[i] = RGB2COLOR(gammatable[usegamma][palette[0]], gammatable[usegamma][palette[1]], gammatable[usegamma][palette[2]]);
    }
}
コード例 #3
0
ファイル: leds.c プロジェクト: TwP/pixel_pi
static int
pp_rgb_to_color( VALUE red, VALUE green, VALUE blue )
{
  int r = FIX2INT(red);
  int g = FIX2INT(green);
  int b = FIX2INT(blue);
  return RGB2COLOR(r, g, b);
}
コード例 #4
0
ファイル: main.c プロジェクト: FriedCircuits/USBMultimeter
void drawGraphLines(GHandle gh)
{
	 //color_t oldColor;
	 //oldColor = gh->color;
//     gh->color=White;
//     //Vertical Line
//     gwinDrawLine(gh, 5,0, 5,gwinGetHeight(gh));
//     gwinDrawLine(gh, 0,(gwinGetHeight(gh)/2)-5, 5,(gwinGetHeight(gh)/2)-5); //half way tick
//     gwinDrawLine(gh, 3,(gwinGetHeight(gh)/4)-5, 5,(gwinGetHeight(gh)/4)-5); //qtr ticks
//     gwinDrawLine(gh, 3,((gwinGetHeight(gh)/4)*3)-5, 5,((gwinGetHeight(gh)/4)*3)-5); //qtr ticks
//     gwinDrawLine(gh, 0,0, 5,0); //top end
//     //Horizontal Line
//     gwinDrawLine(gh, 0,gwinGetHeight(gh)-5, gwinGetWidth(gh),gwinGetHeight(gh)-5);
//     gwinDrawLine(gh, (gwinGetWidth(gh)/2)+5, gwinGetHeight(gh)-5, (gwinGetWidth(gh)/2)+5, gwinGetHeight(gh)); //half way tickhttps://www.google.com/webhp?hl=en
//     gwinDrawLine(gh, (gwinGetWidth(gh)/4)+5, gwinGetHeight(gh)-5, (gwinGetWidth(gh)/4)+5, gwinGetHeight(gh)-3); //qtr tick
//     gwinDrawLine(gh, ((gwinGetWidth(gh)/4)*3)+5, gwinGetHeight(gh)-5, ((gwinGetWidth(gh)/4)*3)+5, gwinGetHeight(gh)-3); //qtr way tick
//     gwinDrawLine(gh, gwinGetWidth(gh)-1, gwinGetHeight(gh)-5, gwinGetWidth(gh)-1, gwinGetHeight(gh)); //bottom end

	coord_t i, j;
	color_t r,g,b;
	coord_t width = gwinGetWidth(gh);
	coord_t height = gwinGetHeight(gh);

	for (i = 0; i < width; i++) {
	   for(j = 0; j < height; j++) {
		   //r = ((((_acgraphH[i+(j*width)] >> 11) & 0x1F)*527)+23) >> 6;
		   //g = ((((_acgraphH[i+(j*width)] >> 5) & 0x3f)*259)+33) >> 6;
		   //b = (((_acgraphH[i+(j*width)])  & 0x1f) + 23) >> 6;
		   if (activeGraph == 3 || gh->parent == ghContainerGraphCV) {
			   r = RED_OF(_acgraphH2[i+(j*width)] >> 11);
			   g = GREEN_OF(_acgraphH2[i+(j*width)] >> 5);
			   b = BLUE_OF(_acgraphH2[i+(j*width)]);
			   surface2[j*width+i]=(RGB2COLOR(r,g,b));
		   } else {
			   r = RED_OF(_acgraphH[i+(j*width)] >> 11);
			   g = GREEN_OF(_acgraphH[i+(j*width)] >> 5);
			   b = BLUE_OF(_acgraphH[i+(j*width)]);
			   surface[j*width+i]=(RGB2COLOR(r,g,b));
		   }
		   //gwinDrawPixel(pixmap,i, j);
	   }
コード例 #5
0
ファイル: main.c プロジェクト: guzhaoyuan/smartCar
/* 接收完成一场后 用户处理函数 */
static void UserApp(void)
{
    uint32_t i,j;
    static uint32_t cnt;
    printf("SYNC cnt:%d\r\n", cnt++);
    for(i=0; i<OV7620_H; i++)
    {
        for(j=0; j<OV7620_W; j++)
        {
            ili9320_write_pixel(OV7620_H - i, OV7620_W- j, RGB2COLOR(CCDBuffer[i][j], CCDBuffer[i][j], CCDBuffer[i][j]));
        }
    }
}
コード例 #6
0
ファイル: mouse.c プロジェクト: niamster/ChibiOS-GFX
	static inline void _tsDrawCross(const MousePoint *pp) {
		gdispDrawLine(pp->x-15, pp->y, pp->x-2, pp->y, White);
		gdispDrawLine(pp->x+2, pp->y, pp->x+15, pp->y, White);
		gdispDrawLine(pp->x, pp->y-15, pp->x, pp->y-2, White);
		gdispDrawLine(pp->x, pp->y+2, pp->x, pp->y+15, White);

		gdispDrawLine(pp->x-15, pp->y+15, pp->x-7, pp->y+15, RGB2COLOR(184,158,131));
		gdispDrawLine(pp->x-15, pp->y+7, pp->x-15, pp->y+15, RGB2COLOR(184,158,131));

		gdispDrawLine(pp->x-15, pp->y-15, pp->x-7, pp->y-15, RGB2COLOR(184,158,131));
		gdispDrawLine(pp->x-15, pp->y-7, pp->x-15, pp->y-15, RGB2COLOR(184,158,131));

		gdispDrawLine(pp->x+7, pp->y+15, pp->x+15, pp->y+15, RGB2COLOR(184,158,131));
		gdispDrawLine(pp->x+15, pp->y+7, pp->x+15, pp->y+15, RGB2COLOR(184,158,131));

		gdispDrawLine(pp->x+7, pp->y-15, pp->x+15, pp->y-15, RGB2COLOR(184,158,131));
		gdispDrawLine(pp->x+15, pp->y-15, pp->x+15, pp->y-7, RGB2COLOR(184,158,131));
	}
コード例 #7
0
ファイル: gdisp_lld.c プロジェクト: DuinoPilot/ChibiOS-GFX
	/**
	 * @brief   Fill an area with a bitmap.
	 * @note    Optional - The high level driver can emulate using software.
	 *
	 * @param[in] x, y     The start filled area
	 * @param[in] cx, cy   The width and height to be filled
	 * @param[in] srcx, srcy   The bitmap position to start the fill from
	 * @param[in] srccx    The width of a line in the bitmap.
	 * @param[in] buffer   The pixels to use to fill the area.
	 *
	 * @notapi
	 */
	void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) {
		BITMAPV4HEADER bmpInfo;
		RECT	rect;
		#if GDISP_NEED_CONTROL
			pixel_t	*srcimg;
		#endif

		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			// Clip pre orientation change
			if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; }
			if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; }
			if (srcx+cx > srccx)		cx = srccx - srcx;
			if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
			if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
			if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
		#endif

		// Make everything relative to the start of the line
		buffer += srccx*srcy;
		srcy = 0;
		
		memset(&bmpInfo, 0, sizeof(bmpInfo));
		bmpInfo.bV4Size = sizeof(bmpInfo);
		bmpInfo.bV4Planes = 1;
		bmpInfo.bV4BitCount = 32;
		bmpInfo.bV4AlphaMask = 0;
		bmpInfo.bV4RedMask		= RGB2COLOR(255,0,0);
		bmpInfo.bV4GreenMask	= RGB2COLOR(0,255,0);
		bmpInfo.bV4BlueMask		= RGB2COLOR(0,0,255);
		bmpInfo.bV4V4Compression = BI_BITFIELDS;
		bmpInfo.bV4XPelsPerMeter = 3078;
		bmpInfo.bV4YPelsPerMeter = 3078;
		bmpInfo.bV4ClrUsed = 0;
		bmpInfo.bV4ClrImportant = 0;
		bmpInfo.bV4CSType = 0; //LCS_sRGB;

		#if GDISP_NEED_CONTROL
			bmpInfo.bV4SizeImage = (cy*cx) * sizeof(pixel_t);
			srcimg = rotateimg(cx, cy, srcx, srccx, buffer);
			if (!srcimg) return;
			
			switch(GDISP.Orientation) {
			case GDISP_ROTATE_0:
				bmpInfo.bV4Width = cx;
				bmpInfo.bV4Height = -cy; /* top-down image */
				rect.top = y;
				rect.bottom = rect.top+cy;
				rect.left = x;
				rect.right = rect.left+cx;
				break;
			case GDISP_ROTATE_90:
				bmpInfo.bV4Width = cy;
				bmpInfo.bV4Height = -cx; /* top-down image */
				rect.top = x;
				rect.bottom = rect.top+cx;
				rect.right = GDISP.Height - y;
				rect.left = rect.right-cy;
				break;
			case GDISP_ROTATE_180:
				bmpInfo.bV4Width = cx;
				bmpInfo.bV4Height = -cy; /* top-down image */
				rect.bottom = GDISP.Height - y;
				rect.top = rect.bottom-cy;
				rect.right = GDISP.Width - x;
				rect.left = rect.right-cx;
				break;
			case GDISP_ROTATE_270:
				bmpInfo.bV4Width = cy;
				bmpInfo.bV4Height = -cx; /* top-down image */
				rect.bottom = GDISP.Width - x;
				rect.top = rect.bottom-cx;
				rect.left = y;
				rect.right = rect.left+cy;
				break;
			}
			SetDIBitsToDevice(dcBuffer, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0, 0, 0, rect.bottom-rect.top, srcimg, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS);
			if (srcimg != (pixel_t *)buffer)
				free(srcimg);
			
		#else
			bmpInfo.bV4Width = srccx;
			bmpInfo.bV4Height = -cy; /* top-down image */
			bmpInfo.bV4SizeImage = (cy*srccx) * sizeof(pixel_t);
			rect.top = y;
			rect.bottom = rect.top+cy;
			rect.left = x;
			rect.right = rect.left+cx;
			SetDIBitsToDevice(dcBuffer, x, y, cx, cy, srcx, 0, 0, cy, buffer, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS);
		#endif

		// Invalidate the region to get it on the screen.
		InvalidateRect(winRootWindow, &rect, FALSE);
		UpdateWindow(winRootWindow);
	}
コード例 #8
0
ファイル: gdisp_image_bmp.c プロジェクト: chrmue44/uRock
gdispImageError gdispImageOpen_BMP(gdispImage *img) {
	gdispImagePrivate *priv;
	uint8_t		hdr[2];
	uint16_t	aword;
	uint32_t	adword;
	uint32_t	offsetColorTable;

	/* Read the file identifier */
	if (gfileRead(img->f, hdr, 2) != 2)
		return GDISP_IMAGE_ERR_BADFORMAT;		// It can't be us

	/* Process the BITMAPFILEHEADER structure */

	/**
	 * We only accept Windows V2+ bitmaps.
	 *  - we don't support OS/2 bitmaps, icons, pointers, or Windows V1 bitmaps.
	 */
	if (hdr[0] != 'B' || hdr[1] != 'M')
		return GDISP_IMAGE_ERR_BADFORMAT;		// It can't be us

	/* We know we are a BMP format image */
	img->flags = 0;

	/* Allocate our private area */
	if (!(img->priv = (gdispImagePrivate *)gdispImageAlloc(img, sizeof(gdispImagePrivate))))
		return GDISP_IMAGE_ERR_NOMEMORY;

	/* Initialise the essential bits in the private area */
	priv = img->priv;
	priv->frame0cache = 0;
	priv->bmpflags = 0;
#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_4_RLE || GDISP_NEED_IMAGE_BMP_8 || GDISP_NEED_IMAGE_BMP_8_RLE
	priv->palette = 0;
#endif

	/* Skip the size field and the 2 reserved fields */
	if (gfileRead(img->f, priv->buf, 8) != 8)
		goto baddatacleanup;

	/* Get the offset to the bitmap data */
	if (gfileRead(img->f, &priv->frame0pos, 4) != 4)
		goto baddatacleanup;
	CONVERT_FROM_DWORD_LE(priv->frame0pos);

	/* Process the BITMAPCOREHEADER structure */

	/* Get the offset to the colour data */
	if (gfileRead(img->f, &offsetColorTable, 4) != 4)
		goto baddatacleanup;
	CONVERT_FROM_DWORD_LE(offsetColorTable);
	offsetColorTable += 14;						// Add the size of the BITMAPFILEHEADER

	// Detect our bitmap version
	if (offsetColorTable == 12+14) {
		img->priv->bmpflags |= BMP_V2;

		// Read the header
		if (gfileRead(img->f, priv->buf, 12-4) != 12-4)
			goto baddatacleanup;
		// Get the width
		img->width = *(uint16_t *)(((uint8_t *)priv->buf)+0);
		CONVERT_FROM_WORD_LE(img->width);
		// Get the height
		img->height = *(uint16_t *)(((uint8_t *)priv->buf)+2);
		CONVERT_FROM_WORD_LE(img->height);
		if (img->height < 0) {
			img->priv->bmpflags |= BMP_TOP_TO_BOTTOM;
			img->height = -img->height;
		}
		// Get the planes
		aword = *(uint16_t *)(((uint8_t *)priv->buf)+4);
		CONVERT_FROM_WORD_LE(aword);
		if (aword != 1)
			goto unsupportedcleanup;
		// Get the bits per pixel
		aword = *(uint16_t *)(((uint8_t *)priv->buf)+6);
		CONVERT_FROM_WORD_LE(aword);
		switch(aword) {
#if GDISP_NEED_IMAGE_BMP_1
		case 1:
#endif
#if GDISP_NEED_IMAGE_BMP_4
		case 4:
#endif
#if GDISP_NEED_IMAGE_BMP_8
		case 8:
#endif
#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_8
			priv->bmpflags |= BMP_PALETTE;
			priv->palsize = 1<<aword;
			break;
#endif
#if GDISP_NEED_IMAGE_BMP_24
		case 24:
			break;
#endif
		default:
			goto unsupportedcleanup;
		}
		priv->bitsperpixel = aword;

	} else if (offsetColorTable >= 40+14) {
		if (offsetColorTable > 40+14)
			priv->bmpflags |= BMP_V4;

		// Read the header
		if (gfileRead(img->f, priv->buf, 40-4) != 40-4)
			goto baddatacleanup;
		// Get the width
		adword = *(uint32_t *)(((uint8_t *)priv->buf)+0);
		CONVERT_FROM_DWORD_LE(adword);
		if (adword > 32768)				// This also picks up negative values
			goto unsupportedcleanup;
		img->width = adword;
		// Get the height
		adword = *(uint32_t *)(((uint8_t *)priv->buf)+4);
		CONVERT_FROM_DWORD_LE(adword);
		if ((int32_t)adword < 0) {		// Negative test
			priv->bmpflags |= BMP_TOP_TO_BOTTOM;
			adword = -adword;
		}
		if (adword > 32768)
			goto unsupportedcleanup;
		img->height = adword;
		// Get the planes
		aword = *(uint16_t *)(((uint8_t *)priv->buf)+8);
		CONVERT_FROM_WORD_LE(aword);
		if (aword != 1)
			goto unsupportedcleanup;
		// Get the bits per pixel
		aword = *(uint16_t *)(((uint8_t *)priv->buf)+10);
		CONVERT_FROM_WORD_LE(aword);
		switch(aword) {
#if GDISP_NEED_IMAGE_BMP_1
		case 1:
#endif
#if GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_4_RLE
		case 4:
#endif
#if GDISP_NEED_IMAGE_BMP_8 || GDISP_NEED_IMAGE_BMP_8_RLE
		case 8:
#endif
#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_4_RLE || GDISP_NEED_IMAGE_BMP_8 || GDISP_NEED_IMAGE_BMP_8_RLE
			priv->bmpflags |= BMP_PALETTE;
			priv->palsize = 1<<aword;
			break;
#endif
#if GDISP_NEED_IMAGE_BMP_16
		case 16:
#endif
#if GDISP_NEED_IMAGE_BMP_24
		case 24:
#endif
#if GDISP_NEED_IMAGE_BMP_32
		case 32:
#endif
#if GDISP_NEED_IMAGE_BMP_16 || GDISP_NEED_IMAGE_BMP_24 || GDISP_NEED_IMAGE_BMP_32
			break;
#endif
		default:
			goto unsupportedcleanup;
		}
		priv->bitsperpixel = aword;
		// Get the compression
		adword = *(uint32_t *)(((uint8_t *)priv->buf)+12);
		CONVERT_FROM_DWORD_LE(adword);
		switch(adword) {
		case 0:					// BI_RGB - uncompressed
			break;
#if GDISP_NEED_IMAGE_BMP_8_RLE
		case 1:					// BI_RLE8 compression
			if (priv->bitsperpixel != 8)
				goto unsupportedcleanup;
			priv->bmpflags |= BMP_COMP_RLE;
			break;
#endif
#if GDISP_NEED_IMAGE_BMP_4_RLE
		case 2:					// BI_RLE4 compression
			if (priv->bitsperpixel != 4)
				goto unsupportedcleanup;
			priv->bmpflags |= BMP_COMP_RLE;
			break;
#endif
#if GDISP_NEED_IMAGE_BMP_16 || GDISP_NEED_IMAGE_BMP_32
		case 3:					// BI_BITFIELDS decoding
			if (priv->bitsperpixel < 16 || priv->bitsperpixel == 24)
				goto unsupportedcleanup;
			priv->bmpflags |= BMP_COMP_MASK;
			if (priv->bmpflags & BMP_V4)		// V4 stored the masks in the header
				offsetColorTable = 40+14;
			break;
#endif
		default:
			goto unsupportedcleanup;
		}
		priv->bitsperpixel = aword;
#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_4_RLE || GDISP_NEED_IMAGE_BMP_8 || GDISP_NEED_IMAGE_BMP_8_RLE
		// Get the actual colors used
		adword = *(uint32_t *)(((uint8_t *)priv->buf)+28);
		CONVERT_FROM_DWORD_LE(adword);
		if (adword && adword < priv->palsize)
			priv->palsize = adword;
#endif
	} else
		goto baddatacleanup;

#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_4_RLE || GDISP_NEED_IMAGE_BMP_8 || GDISP_NEED_IMAGE_BMP_8_RLE
	/* Load the palette tables */
	if (priv->bmpflags & BMP_PALETTE) {
		gfileSetPos(img->f, offsetColorTable);

		if (!(priv->palette = (color_t *)gdispImageAlloc(img, priv->palsize*sizeof(color_t))))
			return GDISP_IMAGE_ERR_NOMEMORY;
		if (priv->bmpflags & BMP_V2) {
			for(aword = 0; aword < priv->palsize; aword++) {
				if (gfileRead(img->f, &priv->buf, 3) != 3) goto baddatacleanup;
				priv->palette[aword] = RGB2COLOR(((uint8_t *)priv->buf)[2], ((uint8_t *)priv->buf)[1], ((uint8_t *)priv->buf)[0]);
			}
		} else {
			for(aword = 0; aword < priv->palsize; aword++) {
				if (gfileRead(img->f, &priv->buf, 4) != 4) goto baddatacleanup;
				priv->palette[aword] = RGB2COLOR(((uint8_t *)priv->buf)[2], ((uint8_t *)priv->buf)[1], ((uint8_t *)priv->buf)[0]);
			}
		}

	}
#endif

#if GDISP_NEED_IMAGE_BMP_16 || GDISP_NEED_IMAGE_BMP_32
	/* Load the bit masks */
	if (priv->bmpflags & BMP_COMP_MASK) {
		gfileSetPos(img->f, offsetColorTable);
		if (gfileRead(img->f, &priv->maskred, 4) != 4) goto baddatacleanup;
		CONVERT_FROM_DWORD_LE(priv->maskred);
		if (gfileRead(img->f, &priv->maskgreen, 4) != 4) goto baddatacleanup;
		CONVERT_FROM_DWORD_LE(priv->maskgreen);
		if (gfileRead(img->f, &priv->maskblue, 4) != 4) goto baddatacleanup;
		CONVERT_FROM_DWORD_LE(priv->maskblue);
		if (priv->bmpflags & BMP_V4) {
			if (gfileRead(img->f, &priv->maskalpha, 4) != 4) goto baddatacleanup;
			CONVERT_FROM_DWORD_LE(priv->maskalpha);
		} else
			priv->maskalpha = 0;
	} else if (priv->bitsperpixel == 16) {
		priv->bmpflags |= BMP_COMP_MASK;
		priv->maskred = 0x7C00;
		priv->maskgreen = 0x03E0;
		priv->maskblue = 0x001F;
		priv->maskalpha = 0;
	} else if (priv->bitsperpixel == 32) {
		priv->bmpflags |= BMP_COMP_MASK;
		priv->maskred = 0x00FF0000;
		priv->maskgreen = 0x0000FF00;
		priv->maskblue = 0x000000FF;
		priv->maskalpha = 0;
	}

	/* We need to adjust the masks and calculate the shift values so the result scales 0 -> 255 */
	if (priv->bmpflags & BMP_COMP_MASK) {
		priv->shiftred = 0;
		priv->shiftgreen = 0;
		priv->shiftblue = 0;
		if (priv->maskred) {
			if (priv->maskred < 256)
				for(adword = priv->maskred;  adword < 128; priv->shiftred--, adword <<= 1);
			else
				for(adword = priv->maskred;  adword > 255; priv->shiftred++, adword >>= 1);
		}
		if (priv->maskgreen) {
			if (priv->maskgreen < 256)
				for(adword = priv->maskgreen;  adword < 128; priv->shiftgreen--, adword <<= 1);
			else
				for(adword = priv->maskgreen;  adword > 255; priv->shiftgreen++, adword >>= 1);
		}
		if (priv->maskblue) {
			if (priv->maskblue < 256)
				for(adword = priv->maskblue;  adword < 128; priv->shiftblue--, adword <<= 1);
			else
				for(adword = priv->maskblue;  adword > 255; priv->shiftblue++, adword >>= 1);
		}
		if (priv->maskalpha) {
			if (priv->maskalpha < 256)
				for(adword = priv->maskalpha;  adword < 128; priv->shiftalpha--, adword <<= 1);
			else
				for(adword = priv->maskalpha;  adword > 255; priv->shiftalpha++, adword >>= 1);
		}
	}
コード例 #9
0
	LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
		winPriv	*		priv;
		pixel_t	*		buffer;
		RECT			rect;
		BITMAPV4HEADER	bmpInfo;

		// Make everything relative to the start of the line
		priv = g->priv;
		buffer = g->p.ptr;
		buffer += g->p.x2*g->p.y1;

		memset(&bmpInfo, 0, sizeof(bmpInfo));
		bmpInfo.bV4Size = sizeof(bmpInfo);
		bmpInfo.bV4Planes = 1;
		bmpInfo.bV4BitCount = COLOR_TYPE_BITS;
		bmpInfo.bV4AlphaMask = 0;
		bmpInfo.bV4RedMask		= RGB2COLOR(255,0,0);
		bmpInfo.bV4GreenMask	= RGB2COLOR(0,255,0);
		bmpInfo.bV4BlueMask		= RGB2COLOR(0,0,255);
		bmpInfo.bV4V4Compression = BI_BITFIELDS;
		bmpInfo.bV4XPelsPerMeter = 3078;
		bmpInfo.bV4YPelsPerMeter = 3078;
		bmpInfo.bV4ClrUsed = 0;
		bmpInfo.bV4ClrImportant = 0;
		bmpInfo.bV4CSType = 0; //LCS_sRGB;

		#if GDISP_NEED_CONTROL
			switch(g->g.Orientation) {
			case GDISP_ROTATE_0:
			default:
				bmpInfo.bV4SizeImage = (g->p.cy*g->p.x2) * sizeof(pixel_t);
				bmpInfo.bV4Width = g->p.x2;
				bmpInfo.bV4Height = -g->p.cy; /* top-down image */
				rect.top = g->p.y;
				rect.bottom = rect.top+g->p.cy;
				rect.left = g->p.x;
				rect.right = rect.left+g->p.cx;
				break;
			case GDISP_ROTATE_90:
				if (!(buffer = rotateimg(g, buffer))) return;
				bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(pixel_t);
				bmpInfo.bV4Width = g->p.cy;
				bmpInfo.bV4Height = -g->p.cx; /* top-down image */
				rect.bottom = g->g.Width - g->p.x;
				rect.top = rect.bottom-g->p.cx;
				rect.left = g->p.y;
				rect.right = rect.left+g->p.cy;
				break;
			case GDISP_ROTATE_180:
				if (!(buffer = rotateimg(g, buffer))) return;
				bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(pixel_t);
				bmpInfo.bV4Width = g->p.cx;
				bmpInfo.bV4Height = -g->p.cy; /* top-down image */
				rect.bottom = g->g.Height-1 - g->p.y;
				rect.top = rect.bottom-g->p.cy;
				rect.right = g->g.Width - g->p.x;
				rect.left = rect.right-g->p.cx;
				break;
			case GDISP_ROTATE_270:
				if (!(buffer = rotateimg(g, buffer))) return;
				bmpInfo.bV4SizeImage = (g->p.cy*g->p.cx) * sizeof(pixel_t);
				bmpInfo.bV4Width = g->p.cy;
				bmpInfo.bV4Height = -g->p.cx; /* top-down image */
				rect.top = g->p.x;
				rect.bottom = rect.top+g->p.cx;
				rect.right = g->g.Height - g->p.y;
				rect.left = rect.right-g->p.cy;
				break;
			}
		#else
			bmpInfo.bV4SizeImage = (g->p.cy*g->p.x2) * sizeof(pixel_t);
			bmpInfo.bV4Width = g->p.x2;
			bmpInfo.bV4Height = -g->p.cy; /* top-down image */
			rect.top = g->p.y;
			rect.bottom = rect.top+g->p.cy;
			rect.left = g->p.x;
			rect.right = rect.left+g->p.cx;
		#endif

		WaitForSingleObject(drawMutex, INFINITE);
		SetDIBitsToDevice(priv->dcBuffer, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0, 0, 0, rect.bottom-rect.top, buffer, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS);
		#if GDISP_WIN32_USE_INDIRECT_UPDATE
			ReleaseMutex(drawMutex);
			InvalidateRect(priv->hwnd, &rect, FALSE);
		#else
			{
				HDC		dc;
				dc = GetDC(priv->hwnd);
				SetDIBitsToDevice(dc, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0, 0, 0, rect.bottom-rect.top, buffer, (BITMAPINFO*)&bmpInfo, DIB_RGB_COLORS);
				ReleaseDC(priv->hwnd, dc);
				ReleaseMutex(drawMutex);
			}
		#endif

		#if GDISP_NEED_CONTROL
			if (buffer != (pixel_t *)g->p.ptr)
				free(buffer);
		#endif
	}