C# :: Colors - Integer Value For Alpha
Jul 14, 2014
I want to use a new color for BaseColor in iTextSharp.
I can easily set a new color using RGB values from 0 to 255.
However, if I want to adjust the alpha value (and I know alpha ranges from 0 to 1), I can't make the alpha 0.5 because it's not an integer in the definition of BaseColor.
public BaseColor(int red, int green, int blue, int alpha);
So I can set my BaseColor like below:
static BaseColor newColor = new BaseColor(192, 192, 192);
but I can't use a non-int value for alpha. How can I easily convert double alpha values to integer values? What would be the range for alpha in int values and how do I, e.g., set the alpha value to 0.5 in int values?
EDIT: btw, I found online something like this: int alpha = (pixel >> 24). I don't understand why 24 and how can I break that into chunks I understand?
View 5 Replies
ADVERTISEMENT
Jun 28, 2014
I found a targa loader that works great and implemented it in my code.
But for some reason, the alpha region of my texture , just won't be alpha when I load the Texture in my code.
If I make a texture that is a full purple colored rectangle, and carve out the central part with an alpha zone, in-game the quad is all full purple, instead of having the central part being transparent.
I tried the following code too, and it doesn't work, I don't understand
//NPC
glEnable(GL_BLEND);// Enable Blending
NPC00->Draw();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);// Set The Blending To A Nice 50/50 Mode
glDisable(GL_BLEND);// Disable Blending
Draw Function, basically draws a Quad and applies the texture to it.
I'm just trying to get textures with alpha to work, I usually work with targas, so thats why I got a targa loader.
View 1 Replies
View Related
Sep 18, 2013
I want to change the alpha of a sprite without changing any other colours
View 4 Replies
View Related
Jul 9, 2014
I made this function to check in string is alpha only or alphanumeric but always give me alfa way ?
Code:
int checkIfStringisAlfa(const char str[]){
int lenStr = getStringLength(str);
int i = 0;
int ret;
for(i = 0; i < lenStr; i++){
if(str[i] >= 'a' && str[i] <= 'z' || str[i] >= 'A' && str[i] <= 'Z'){
//printf(" alfa
[Code] .....
View 8 Replies
View Related
Nov 7, 2013
I am looking for a way to sort a string just by the alpha characters, not by the ASCII table. Therefore
string sort(string name) {
sort(name.begin(), name.end());
return name;
}
will not work. And I am looking for the most simple way to go about it!
View 7 Replies
View Related
Aug 21, 2013
I am currently using Dev-C++ 4.9.9.2 compiler for creating a C project. I need few strings to be printed in a different color.
Code:
#include<stdio.h>
#include<conio.h>
int main(void)
{ textcolor(RED);
cprintf("Hello world
");
system("pause");
}
While I use " textcolor(RED) " it says: 'RED' undeclared, first use in this function.
If i make it: " textcolor(3) ", it says: [Linker error] undefined reference to textcolor & undefined reference to cprintf.
have been searching for a solution on google since morning. At last I could make out that it is not the correct compiler with suitable library or outdated <conio.h> header file.
I had switched from turbo(or borland, I don't remember) to Dev-C++ compiler due to some kind of library issue. Now I guess I'll have to switch to some other IDE. Which one is that, I don't know yet. There was another thread also about this topic, but didn't provide any solution.
Is there any method to upgrade certain header file (I don't think so)? What would be the best IDE with updated libraries?
View 7 Replies
View Related
Nov 8, 2014
I want to write a function called DrawLineSegments.This function must change the color of lines at every corner where the corner angle is greater than 60 deg (Assume that there is a function called checkangle). The color sequence must be black, red, green, blue, and repeat this sequence after the fourth color.
View 1 Replies
View Related
Nov 3, 2013
How to stalk a random alpha letter in order in a minimum possible way.. and write the cases which the container can be stalked.
for example.. ACMICPC can be a store in three stalks.
ACC
M -----------> three stalks
IP
Another example... CBACBACBACBACBA can have three stalks
View 12 Replies
View Related
Jun 27, 2014
I'm trying to load a Quad with a Monster Image on it that will always face the Camera, a la Doom 2.
Now I don't know how to load an image with an Alpha part on it.
In 2D using SDL I always used tga files.
Here is my LoadTexture functions.
AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle
[Code].....
View 2 Replies
View Related
Feb 17, 2013
I'm generating all ncurses color pairs like this
Code:
void generate_all_color_pairs(){ int foreground;
int background;
int i = 0;
for(foreground=0; foreground<8; foreground++){
for(background=0; background<8; background++){
i++;
[code]....
but according on several sources, some terminals suport more colors.Is there any way to determine how many colors the current terminal supports?
View 3 Replies
View Related
Oct 5, 2013
I want to detect colors that in the black rectangle. [URL] How can I do? What library should I use?
View 7 Replies
View Related
Feb 6, 2015
I found this elegant looking code on the net that claims to be able to manipulate an images colors using ColorMatrix.
When I run it, it does nothing! I used the code exactly as is with no editing, except to feed it my own image to do its work.
private void ApplySaturation(float saturation) {
float rWeight = 0.3086f;
float gWeight = 0.6094f;
float bWeight = 0.0820f;
float a = (1.0f - saturation) * rWeight + saturation;
[code].....
View 8 Replies
View Related
Nov 20, 2012
I am unable to check if the character in the 2D array is alpha
here is my code
#include<iostream>
#include<cctype>
#include<cassert>
#include<cstring>
const int maxChar = 20 ;
using namespace std ;
int main() {
int count = 0 ;
char d[2][20] = { "hi" , "di" } ;
[code]....
View 8 Replies
View Related
Jan 19, 2014
I'm trying to make colors transparent in c++ using a 3rd party library. I've successful made my background transparent but I feel I'm cheating by not understanding how I entered the value.
"0xff, 0xff, 0xff" is the color white but i'm not sure how it's the color white like with RGB values.
View 5 Replies
View Related
Aug 31, 2014
Basically I am making a console RPG (isn't every beginner nowadays?) and I am having an incredible amount of trouble assigning specific characters their own color. e.g. monsters being red, cash being green, etc.
I took out Left, Right, and Down controls because of character constraint.
#include <iostream>
#include <windows.h>
//%%%%%%%%%%%%%% COLOR CALL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void setcolor(unsigned short color) {
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hcon,color);
[code]....
View 8 Replies
View Related
Oct 10, 2012
Why the first code snippet inserts properly into a list and the second code snippet does not. The position of the bold expressions are the only differences. iter, s and LS were declared elsewhere in main().
snippet 1.)
while (true) {
cout << "Enter string (ENTER to exit): ";
getline(cin, s);
if (s.size() == 0)
[Code] .....
View 2 Replies
View Related
Apr 22, 2013
I am currently starting to attempt to make a program that can move my cursor to certain colors on my monitor. The problem is this seems like it will be 10x harder than I first thought.
View 4 Replies
View Related
Jun 29, 2013
Suppose I have a txt file that I want the contents printed to the console in such a way that every five words are colored blue and the following five are red. How do I accomplish such a task? I am currently only able to print the contents of the file in regular color using ifstream.
View 1 Replies
View Related
Jul 15, 2014
I made my own custom message/dialog box.
I have a template mock up view using xaml. I have a viewmodel that raises the message property. I binded the message property to a textblock inside my xaml.
Since my messages are different for every viewmodel I have.
E.g.in every viewmodel, I have something like
messagewindow.Message = "This is a new message";
dialogService.ShowDialog(Success, messageWindow);
In one of my messages, I want to make the font bold and different color for a specific message segment.
How can I do that without messing up with the other messages that inherit from the xaml or code behind?
Currently, I'm not using any code behind and a lot of the examples online I've seen use code behind and/or don't have dynamic message textboxes.
View 5 Replies
View Related
Apr 25, 2013
I want to create 2 functions to (1) convert a passed string into proper case (capitalize the first alpha character of a string and every alpha character that follows a non-alpha character); (2) sort the array of names (after it has been converted to proper case).
I tried these two:
console.writeline (lower.toUpper());
void bubblesort (string array[],int length);
but I don't know if they are good.
View 2 Replies
View Related
Oct 25, 2013
I am trying to assign the integer value to unsigned char array. But it is not storing the integer values. It prints the ascii values. Here the code snippet
Code: uchar uc[100];
for(i=0;i<100;i++)
{
uc[i] = i;
}
The values which are stored in uc[] is ascii values.I need the integer values to be stored in uc[]. I tried to do it with sprintf. but the output is not as expected. if I print the uc[i] it should diplay the value as 0,1,2....99.
View 9 Replies
View Related
Jun 15, 2014
changing a 9 digit integer into a new 9 digit integer through simple mathematical operations. For example, I need to change 123456789 into the new digit 456123789. Sometimes I need to change a 9 digit integer into an 8 digit integer. An example is 789062456 into 62789456. I can ONLY use simple mathematical operations (addition, subtraction, multiplication, division and modulo).
View 4 Replies
View Related
Oct 15, 2014
Complete the function myitohex so that its converts 8-byte integer to string based hexadecimals.
Ex: printf("0x%s",myitohex(64,hex)); should printout "0x40" on the screen
char *myitohex(uint8_t i, char *result){
???
return result;
}
I wrote:
#include <stdio.h>
#include <stdint.h>
char *myitohex(uint8_t i, char *result){
*result = i + '0';
[Code] ....
0xp gets printed out which is wrong. I think *result = i + '0'; is wrong. What changes should i do on this row ?
View 4 Replies
View Related
Mar 6, 2015
I have an assignment that calls for a C program using a for loop AND a while loop that will receive an integer (called daNumba) and double it -- Using the integer the program will call the sumFor function and then the sumWhile function. These functions will both sum the values from daNumba to (daNumba * 2) ifdaNumba is positive. If daNumba is not positive it will add the values from (daNumba*2) to daNumba. Both functions will receive the value of daNumba and return a summed value. The only difference between the 2 functions is that sumFor will only use for loops and sumWhile will only use while loops. We are not to use arrays.
The program compiles without error. So far my while loop works for positive integers, but not with a negative integer (I have it commented out) I cannot get the for loop to work properly This is what I have so far -- I am stuck....
Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main () {
[Code] ....
View 12 Replies
View Related
Jul 8, 2013
i have the following problem to solve.... im unable even to start with an idea....can anybody help me giving an idea how to do this problem?
the problem is:
___*****____
Write a C++ program that factorize an integer n into p and q.
Step1. reads an integer n from the keyboard.
Step2. Write a for loop as below to check if there is any factor j > 1.
for (int j = 2; j <= square root of n; j ++)
{
If (n % j == 0)
{
factorizable = true;
break;
}
}
Step3. If there is no such factor, print the message n is not factorizable. If there is such a factor j,
check programmatically if j is a prime and n / j is a prime Also check if j and n / j are the same.
___****___
View 8 Replies
View Related
May 19, 2014
How can I add integer value to a stringstream or read an integer value from it?
View 1 Replies
View Related