Friday, November 17th 2017, 6:27pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

amit251291

Beginner

Date of registration: Oct 28th 2015

Posts: 65

1

Monday, April 4th 2016, 1:44pm

[Solved] Alpha blending with text widget

I was trying Alpha blending effect. i tried 2 approaches , one without any window and other with window. I was successful to make alpha blending effect without window however i failed to do it with window and text widget. Here text is not mixed with the background.

For without window operation i used following code snippet and it worked. Image is attached :


C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
GUI_SetColor(GUI_WHITE);
 GUI_SetFont(&GUI_Font24B_ASCII); 
GUI_DispStringHCenterAt("Maria Jos \n ID= 24358915 \n Duration=21:45 \nAge =45", 100, 120); 
GUI_SetColor(GUI_RED); 
for (i = 0; i < 100; i++) 
{ 
 U8 Alpha; 
 Alpha = (i * 255 / 100); 
GUI_SetAlpha(Alpha); 
 GUI_DrawHLine(240 - i, 0, 320);
 } 
GUI_SetAlpha(0);


code for "with window" operation is attached. Can anybody help me to achieve the alpha blending for text widget on a window created by dialogue box ?
amit251291 has attached the following image:
  • Alpha_withoutWindow.png
amit251291 has attached the following files:

This post has been edited 1 times, last edit by "amit251291" (May 3rd 2016, 11:48am)


amit251291

Beginner

Date of registration: Oct 28th 2015

Posts: 65

2

Wednesday, April 6th 2016, 7:33am

Can anybody tell how to achieve same above effect (shown in image) with text widget ?

amit251291

Beginner

Date of registration: Oct 28th 2015

Posts: 65

3

Monday, April 25th 2016, 7:08am

Someone please through light on this.

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 410

4

Friday, April 29th 2016, 3:47pm

Hello amit,

please try the following:

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "DIALOG.h"

/*********************************************************************
*
*   	_cbWindow
*/
static void _cbWindow (WM_MESSAGE * pMsg) {
  GUI_RECT Rect;
  switch (pMsg->MsgId) { 
  case WM_PAINT: 
	GUI_SetBkColor(GUI_BLACK);
	GUI_Clear();
	GUI_SetColor(GUI_WHITE);
	GUI_SetTextMode(GUI_TM_TRANS);
	GUI_DispString("Test\nTest\nTest\nTest\nTest\nTest\nTest\nTest\nTest\nTest\nTest\nTest\nTest\nTest\nTest\nTest\n");
	WM_GetClientRect(&Rect);
	GUI_EnableAlpha(1);
	GUI_DrawGradientV(Rect.x0, Rect.y0, Rect.x1, Rect.y1, GUI_TRANSPARENT, GUI_RED);
	GUI_EnableAlpha(0);
	return; 
  }
}

/*********************************************************************
*
*   	_cbBk
*/
static void _cbBk(WM_MESSAGE * pMsg) {
  int xSize;
  int ySize;

  switch (pMsg->MsgId) {
  case WM_PAINT:
	xSize = LCD_GetXSize();
	ySize = LCD_GetYSize();
	GUI_DrawGradientH(0, 0, xSize, ySize, GUI_BLACK, GUI_GRAY);
	break;
  }
}

/*********************************************************************
*
*   	MainTask
*/
void MainTask(void) {
  GUI_Init();
  WM_SetCallback(WM_HBKWIN, _cbBk);
  WINDOW_CreateEx(0, 0, 200, 200, WM_HBKWIN, WM_CF_SHOW, 0x0, 0, _cbWindow);
  while (1) {
	GUI_Delay(10);
  }
}


Regards,
Sven

amit251291

Beginner

Date of registration: Oct 28th 2015

Posts: 65

5

Monday, May 2nd 2016, 7:21am

Thanks Schoenen..
But i want to know how this same effect is possible with Text Widget ?.. How to achieve this effect if "Test" is a text widget instead of "GUI_DispString" ?

amit251291

Beginner

Date of registration: Oct 28th 2015

Posts: 65

6

Tuesday, May 3rd 2016, 11:47am

[Solved] Alpha blending with text widget

Thanks Schoenen.. I achieved it by using custom callback function for TextWidget..

Similar threads