C/C++ :: Enable User To Upload Image And Convert It Into ASCII Text Using SDL
Apr 29, 2015
Using C . I have been tasked (for a University assignment) to create a program that will enable a user to upload an image and convert that image into ASCII text using SDL on a Linux system. I've managed to open a window, display an image (non-selected) and convert it into grayscale using
case SDLK_g:
for (int y = 0; y < image->h; y++) {
for (int x = 0; x < image->w; x++) {
Uint32 pixel = pixels[y * image->w + x];
Uint8 r = pixel >> 16 & 0xFF;
Uint8 g = pixel >> 8 & 0xFF;
Uint8 b = pixel & 0xFF;
Uint8 v = (0.212671*r)+(0.715160*g)+(0.072169*B)/>;
pixel = (0xFF << 24) | (v << 16) | (v << 8) | v;
pixels[y * image->w + x] = pixel;
I am absolutely clueless as to how I can get the user to upload an image to the program and then begin the image -> ASCII conversion. I've found seem to be written in C++ or C# to make the conversion I should be using the GetPixelColour command?
I am having a lot of trouble trying to save and upload a data table from a text file ,the data table which is bound to a datagrid, creates its own columns at the formloading event, and everytime a user clicks a button row is added to the data table. With the loading i put this code which i thought would read a text file and put all the content my datatable however a exception pops up saying Duplicate Name exeption. Heres the loading piece of code :
{ string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\DG1.txt "; if(File.Exists(filePath)) { StreamReader reader = new StreamReader(filePath); string line = reader.ReadLine();
I am making a text encrypter and I have to convert text into ASCII codes. I know how to convert a single character into ASCII -
#include <iostream> using namespace std; int main() { cout<<"Text to ASCII converter"<<endl<<"Enter text to convert into ASCII - "; char text; //defining input type, which is single character
[Code] ....
Try it here - URL.....Is there any way to run a similar program, which converts a string with spaces into ASCII code?
i am doing an embedded project on avr microcontroller ATmega8515.actually my project is smart card based electricity billing using UART interfacing..so in this module HEX to ASCII conversion is not possible for me...
The code is supposed to convert characters from an array into their respective ascii integers, and append a 0 if the number is less than 3 digits long. It then supposed to put it all together into one string.
Code: #include <stdio.h> #include <string.h> #include <stdlib.h> int main(void){
char file[] = "This is a test"; char *ptr = file; int length = strlen(file); int i, numbers[length];
I need to make program which converts text (letters and digits only) into 7-digit ascii code. The start and end code is "1100011", so it must not appear inside the output code, thus a zero should be added in it (11000011).
Not that it matters much what my task is - I have a problem. Here's the code:
Code: #include <iostream> #include <stdlib.h> using namespace std; int main() { string in,out="",pk="1100011"; getline(cin,in);
[Code] ....
The 'pk' string loses its value here when I enter a character in the input and I cant figure out why... I got that the problem is somewhere in the first if loop, since the code prints pk nicely when cout is before the loop (comment 1)..however, after the loop (comment 2) it prints nothing..... When compiled, it works nice when I input numbers, but 1 character - and 'pk' disappears...
This is a small program that reads a line from the screen, takes the ASCII values from the entered text, and edits it. Next, the ASCII values are reinterpreted (am i misspelling?) as text, and displayed. However, my final output has (allways?) at least 7 characters, even if you enter only one. I'm also trying to accomplish, that the part of the string which isn't filled, will be printed empty. In spaces.
compiled with -std=c99.
Code: #include <stdio.h> int main(){ int maxsize; printf("How long is your message?
I'm looking to convert audio, images, video to base64 in c++, and through many searches on the web I've only seem to come up with string > base64.
When I view a .mp3 file for example, there are many characters there that are not available to be used in my string to encode.
[URL] ....
I have this code set up in my project, and all I want is to be able to give the location of any file and have it encode (could just encode to a string, I can handle writing it to a file), and then give a location to put the decoded file as well.
Program that reads in a normal text file and converts it into mobile phone text. that is if the word is 3 characters or less then ther is no changes to the word and if the word is four or more letters then remove all the vowels from the word except for vowels that are capitals.
In short I'm converting a floating point bilinear image resampling routine into one that only uses fixed point arithmetic. I've gotten rid of nearly all the floats now, in fact all but one and the results at the moment are in distinguishable from the floating point version. It's a maths issue really. Some pseudocode goes like this.
Code: for( int xx=0; xx<ow; xx++ ) { int_center = (ccx >> 16); int temp = xx * 2; for (j = int_center; j <= int_center + 1; j++)
[Code] ....
Where ccx is and integer error accumulator that gives me a scaled integer. Shifting down buy 16 gives me the relative pixel I need to be working on. The line just after where the inner loop begins is where I have the last remaining float. FILTER_FACTOR is essentially a percentage by which I scale the error accumulator to the correct amount.
For example.
ccx = 98303. Which is a value of 1.5 when shited down by 16 bits. Obviously I can shift it because it will round and I lose the precision. Lets say FILTER_FACTOR is 39321. Which is 60% of 1 (65535) So what I'd like to know is, is it possible to use the FILTER_FACTOR as an integer and do some fancy integer math to scale the result from (ccx - (j<<16)) by the representative amount that is FILTER_FACTOR. In this example 60%. Effectively getting 40% of (ccx - (j<<16)) At the moment FILTER_FACTOR is still a float and therefore 0.6, which of course works just fine.
I'm pretty new to C, just looking to see how to display a image and some text to go along with it so far I can display in the image but cannot display the text at the same time.
So I am upgrading the system from 3.5 .NET to 4.5.1 and fixing any bug that I could find. Long story short, I run into an issue that basically tell me it couldn't find the images in the resource file. I figured out a work around, but first I have to set the picture box or background Image in design time to none. I ran into this Properties Windows while changing the value of picturebox for my user control saying: Property value is not valid. Object reference not set to an instance of an object. This usercontrol is taken from another user control from a different project. Basically, we are reusing it.
I want to create a program using c++ which will accept text from the user and then adds it onto a image of a form in specific locations (if that makes sense?)
My assignment is to pixelate an image based on users input. I have a structure that stores the image, and in this structure I'm storing the height and width and a dynamic array of RGBA struct.
This is my function. my main issue (that I've found) is offsetting and figuring out a way to handle the "edge" if the dimensions don't add up to the set pixelation size.
My goal is to have couple of items in the listbox and when highlighting one item a image in the picturebox should appear, and so on for each item in the listbox.I just don't know how to change image depending on selected item in the listbox instantly.Also when i highlight item a text in label should be like in highlighted item in listbox.
working on this code I have encountered a few issues. My program lists the occurrence of each letter but i'm unsure of how to enable numeric variables. how to improve the overall quality of the code.
Code:
#include <stdio.h> #include <string.h> int main() { char string[100], ch; int c = 0, count[26] = {0}; printf("Enter a string
i have tried to search on the Internet but haven't found a suitable result that links in with what I want to do, that is to creation a WPF application and when you press a enable button it will enable the LAN and when I click the disable button it will disable the LAN until i click the enable button again. Now I know how to creation a WPF and the buttons, but how would I do the disabling LAN and enabling LAN?
By LAN i mean just the networking adapters, so that the PC cannot connect to a router and then the Internet.