It is pointless to operate only in Cxxdroid; it must be successfully compiled in Termux in order to be integrated into the system. The code that I have already written has been continuously improved through repeated use, and when combined, it creates a powerful system. This is my first attempt at compiling my own C language code in Termux. Although I had already written over 2,000 lines of code in Cxxdroid, I did not initially realize that I was using a language that was a mix of C and C++. At first, I tried many different tools, but every attempt to compile directly failed. The usage of each compilation tool was very complicated and had many parameters. Simply browsing through once would take a long time. Eventually, I started with the simplest method and split the code into parts. Once each part was successfully compiled, I combined them again. If I encountered a problem, I would research it, which sometimes took an entire day of effort. Finally, it was successfully compiled. Some parts of the code had to be modified to work properly. Learning to use compilation tools is more difficult than learning the language itself because of the many parameters and complex steps. If everything works without any issues, I would rather not explore it further.
colors.sh and t.sh to compile the code in Termux:
g++ -Wall -Wextra -g -std=c++2a colors.cpp -o ~/bin/colors -lstdc++ -lz -lncursesw -ljpeg -lpng -fopenmp -lpanel -lm
g++ -Wall -Wextra -g -std=c++20 t.cpp -o ~/bin/t -lstdc++ -lz -lncursesw -ljpeg -lm -lpng
Print matrix with colors directly in C language:
void printMatrixC() {
for (int y = 0; y < getHeight(); y++) {
for (int x = 0; x < getWidth(); x++) {
Point2D point = {(double)x, (double)y};
unsigned char value = getValue(point);
// Choose the background color based on the value
int backgroundColor = (int)value;
// Set the background color and print a space
printf("\033[48;5;%dm ", backgroundColor);
}
printf("\n");
}
}
Corrected the issue of dimming in Termux and also optimized the calculation process.
The transformation involving a lot of sine and cosine calculations, but in reality, it does not require a very high precision. By using the method of precomputing approximate values of sine and cosine for 0-360 degrees, the amount of calculations can be greatly reduced.
const float sinTable[360]={0.000,0.017,0.035,0.052,0.070,0.087,0.105,0.122,0.139,0.156,0.174,0.191,0.208,0.225,0.242,0.259,0.276,0.292,0.309,0.326,0.342,0.358,0.375,0.391,0.407,0.423,0.438,0.454,0.469,0.485,0.500,0.515,0.530,0.545,0.559,0.574,0.588,0.602,0.616,0.629,0.643,0.656,0.669,0.682,0.695,0.707,0.719,0.731,0.743,0.755,0.766,0.777,0.788,0.799,0.809,0.819,0.829,0.839,0.848,0.857,0.866,0.875,0.883,0.891,0.899,0.906,0.914,0.920,0.927,0.934,0.940,0.946,0.951,0.956,0.961,0.966,0.970,0.974,0.978,0.982,0.985,0.988,0.990,0.993,0.995,0.996,0.998,0.999,0.999,1.000,1.000,1.000,0.999,0.999,0.998,0.996,0.995,0.993,0.990,0.988,0.985,0.982,0.978,0.974,0.970,0.966,0.961,0.956,0.951,0.946,0.940,0.934,0.927,0.921,0.914,0.906,0.899,0.891,0.883,0.875,0.866,0.857,0.848,0.839,0.829,0.819,0.809,0.799,0.788,0.777,0.766,0.755,0.743,0.731,0.719,0.707,0.695,0.682,0.669,0.656,0.643,0.629,0.616,0.602,0.588,0.574,0.559,0.545,0.530,0.515,0.500,0.485,0.470,0.454,0.438,0.423,0.407,0.391,0.375,0.358,0.342,0.326,0.309,0.292,0.276,0.259,0.242,0.225,0.208,0.191,0.174,0.156,0.139,0.122,0.105,0.087,0.070,0.052,0.035,0.018,0.000,-0.017,-0.035,-0.052,-0.070,-0.087,-0.104,-0.122,-0.139,-0.156,-0.174,-0.191,-0.208,-0.225,-0.242,-0.259,-0.276,-0.292,-0.309,-0.326,-0.342,-0.358,-0.375,-0.391,-0.407,-0.423,-0.438,-0.454,-0.469,-0.485,-0.500,-0.515,-0.530,-0.545,-0.559,-0.574,-0.588,-0.602,-0.616,-0.629,-0.643,-0.656,-0.669,-0.682,-0.695,-0.707,-0.719,-0.731,-0.743,-0.755,-0.766,-0.777,-0.788,-0.799,-0.809,-0.819,-0.829,-0.839,-0.848,-0.857,-0.866,-0.875,-0.883,-0.891,-0.899,-0.906,-0.914,-0.920,-0.927,-0.934,-0.940,-0.945,-0.951,-0.956,-0.961,-0.966,-0.970,-0.974,-0.978,-0.982,-0.985,-0.988,-0.990,-0.993,-0.995,-0.996,-0.998,-0.999,-0.999,-1.000,-1.000,-1.000,-0.999,-0.999,-0.998,-0.996,-0.995,-0.993,-0.990,-0.988,-0.985,-0.982,-0.978,-0.974,-0.970,-0.966,-0.961,-0.956,-0.951,-0.946,-0.940,-0.934,-0.927,-0.921,-0.914,-0.906,-0.899,-0.891,-0.883,-0.875,-0.866,-0.857,-0.848,-0.839,-0.829,-0.819,-0.809,-0.799,-0.788,-0.777,-0.766,-0.755,-0.743,-0.731,-0.719,-0.707,-0.695,-0.682,-0.669,-0.656,-0.643,-0.629,-0.616,-0.602,-0.588,-0.574,-0.559,-0.545,-0.530,-0.515,-0.500,-0.485,-0.470,-0.454,-0.438,-0.423,-0.407,-0.391,-0.375,-0.358,-0.342,-0.326,-0.309,-0.292,-0.276,-0.259,-0.242,-0.225,-0.208,-0.191,-0.174,-0.157,-0.139,-0.122,-0.105,-0.087,-0.070,-0.052,-0.035,-0.018};
const float cosTable[360]={1.000,1.000,0.999,0.999,0.998,0.996,0.995,0.993,0.990,0.988,0.985,0.982,0.978,0.974,0.970,0.966,0.961,0.956,0.951,0.946,0.940,0.934,0.927,0.921,0.914,0.906,0.899,0.891,0.883,0.875,0.866,0.857,0.848,0.839,0.829,0.819,0.809,0.799,0.788,0.777,0.766,0.755,0.743,0.731,0.719,0.707,0.695,0.682,0.669,0.656,0.643,0.629,0.616,0.602,0.588,0.574,0.559,0.545,0.530,0.515,0.500,0.485,0.469,0.454,0.438,0.423,0.407,0.391,0.375,0.358,0.342,0.326,0.309,0.292,0.276,0.259,0.242,0.225,0.208,0.191,0.174,0.156,0.139,0.122,0.105,0.087,0.070,0.052,0.035,0.017,0.000,-0.017,-0.035,-0.052,-0.070,-0.087,-0.105,-0.122,-0.139,-0.156,-0.174,-0.191,-0.208,-0.225,-0.242,-0.259,-0.276,-0.292,-0.309,-0.326,-0.342,-0.358,-0.375,-0.391,-0.407,-0.423,-0.438,-0.454,-0.469,-0.485,-0.500,-0.515,-0.530,-0.545,-0.559,-0.574,-0.588,-0.602,-0.616,-0.629,-0.643,-0.656,-0.669,-0.682,-0.695,-0.707,-0.719,-0.731,-0.743,-0.755,-0.766,-0.777,-0.788,-0.799,-0.809,-0.819,-0.829,-0.839,-0.848,-0.857,-0.866,-0.875,-0.883,-0.891,-0.899,-0.906,-0.914,-0.920,-0.927,-0.934,-0.940,-0.946,-0.951,-0.956,-0.961,-0.966,-0.970,-0.974,-0.978,-0.982,-0.985,-0.988,-0.990,-0.993,-0.995,-0.996,-0.998,-0.999,-0.999,-1.000,-1.000,-1.000,-0.999,-0.999,-0.998,-0.996,-0.995,-0.993,-0.990,-0.988,-0.985,-0.982,-0.978,-0.974,-0.970,-0.966,-0.961,-0.956,-0.951,-0.946,-0.940,-0.934,-0.927,-0.921,-0.914,-0.906,-0.899,-0.891,-0.883,-0.875,-0.866,-0.857,-0.848,-0.839,-0.829,-0.819,-0.809,-0.799,-0.788,-0.777,-0.766,-0.755,-0.743,-0.731,-0.719,-0.707,-0.695,-0.682,-0.669,-0.656,-0.643,-0.629,-0.616,-0.602,-0.588,-0.574,-0.559,-0.545,-0.530,-0.515,-0.500,-0.485,-0.470,-0.454,-0.438,-0.423,-0.407,-0.391,-0.375,-0.358,-0.342,-0.326,-0.309,-0.292,-0.276,-0.259,-0.242,-0.225,-0.208,-0.191,-0.174,-0.157,-0.139,-0.122,-0.105,-0.087,-0.070,-0.052,-0.035,-0.018,-0.000,0.017,0.035,0.052,0.070,0.087,0.104,0.122,0.139,0.156,0.174,0.191,0.208,0.225,0.242,0.259,0.276,0.292,0.309,0.325,0.342,0.358,0.375,0.391,0.407,0.423,0.438,0.454,0.469,0.485,0.500,0.515,0.530,0.545,0.559,0.574,0.588,0.602,0.616,0.629,0.643,0.656,0.669,0.682,0.695,0.707,0.719,0.731,0.743,0.755,0.766,0.777,0.788,0.799,0.809,0.819,0.829,0.839,0.848,0.857,0.866,0.875,0.883,0.891,0.899,0.906,0.914,0.920,0.927,0.934,0.940,0.945,0.951,0.956,0.961,0.966,0.970,0.974,0.978,0.982,0.985,0.988,0.990,0.993,0.995,0.996,0.998,0.999,0.999,1.000};
angle = angle %360;
if (angle<0) angle+=360;
=
double newX = oldPoint.x * cosTable[angle] + oldPoint.y * sinTable[angle];
double newY = oldPoint.y * cosTable[angle] - oldPoint.x * sinTable[angle];
All possible methods that can currently be thought of have been used for optimization.
Every time I try to realize a new idea, I work on it through research and implementation. I try to implement the best method I found during my research. The knowledge and skills I acquire during this process may be expendable, but the completed code is something that must be preserved. This code contains the accumulated efforts and creations over a long period of time. When facing similar problems in the future, I can improve upon this foundation and efficiently complete various complex tasks.
When using the C language to implement these ideas, I have optimized the process to achieve high-efficiency function that completes a series of tasks simultaneously. This advanced function can greatly simplify the process of solving real-world problems, accelerating the completion of various complex ideas. Even without the need for advanced languages, developing a high-level function that processes characters and manages processes can efficiently complete all tasks.
struct Color
{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
};
Istruct Image
{
int width;
int height;
Color *array;
int getIndex(int x, int y)
{
return y * width + x;
}
Image(int w, int h, Color color = {NULL, NULL, NULL, NULL})
{
width = w;
height = h;
array = (Color *)malloc(width * height * sizeof(Color));
if (array == NULL)
{
fprintf(stderr, "Failed to allocate memory for array\n");
exit(EXIT_FAILURE);
}
for (int i = 0; i < width * height; i++)
{
array[i] = color;
}
}
~Image()
{
free(array);
}
int getWidth()
{
return width;
}
int getHeight()
{
return height;
}
Color getPoint(Point2D point)
{
int x = round(point.x);
int y = round(point.y);
if (x < 0 || x >= width || y < 0 || y >= height)
{
return {0, 0, 0, 0};
}
return array[getIndex(x, y)];
}
void setPoint(Point2D point, Color color)
{
int x = round(point.x);
int y = round(point.y);
if (x < 0 || x >= width || y < 0 || y >= height)
{
return;
}
array[getIndex(x, y)] = color;
}
void set(int x, int y, Color color)
{
array[y * width + x] = color;
}
Color get(int x, int y)
{
return array[y * width + x];
}
Point2D getCenter()
{
return {width / 2.0, height / 2.0};
}
void clear(Color color)
{
for (int i = 0; i < width * height; i++)
{
array[i] = color;
}
}
Image rotated(int angle, double resized = 1.42, int cX = NULL, int cY = NULL, int oX = NULL, int oY = NULL, int angleXZ = 0, int angleYZ = 0)
{ //double k=0.174;
angle = angle % 360;
if (angle < 0)
angle += 360;
if (angleXZ != 0)
{
angleXZ = angleXZ % 360;
if (angleXZ < 0)
angleXZ += 360;
}
if (angleYZ != NULL)
{
angleYZ = angleYZ % 360;
if (angleYZ < 0)
angleYZ += 360;
}
Image rotatedImage(width, height);
Point2D center = getCenter();
if (cX != NULL)
{
center.x = cX;
}
if (cY != NULL)
{
center.x = cY;
}
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Point2D oldPoint = {(double)x, (double)y};
oldPoint.x -= center.x;
oldPoint.y -= center.y;
int newX = oldPoint.x * cosTable[angle] + oldPoint.y * sinTable[angle];
int newY = oldPoint.y * cosTable[angle] - oldPoint.x * sinTable[angle];
int tempX = newX;
int tempY = newY;
if (angleXZ != 0)
{
newY = tempY / cosTable[angleXZ];
}
if (angleYZ != 0)
{
newX = tempX / cosTable[angleYZ];
}
if (resized != 1)
{
newX = newX * resized;
newY = newY * resized;
}
newX += center.x;
newY += center.y;
if (newX < 0 || newX >= width || newY < 0 || newY >= height) continue;
Color color = get(newX, newY);
int rX = x;
int rY = y;
if (oX != NULL)
{
rX += oX;
}
if (oY != NULL)
{
rY += oY;
}
if (rX < 0 || rX >= width || rY < 0 || rY >= height) continue;
rotatedImage.set(rX, rY, color);
}
}
return rotatedImage;
}
};
Almost finished running on Cxxdroid and Termux, now I'm planning to start the next project.
Actually, the process of development is a continuous process of improvement through testing. The first code written inevitably hides countless problems. If there are efficient and comprehensive testing methods, all potential problems can be identified in the shortest possible time. It is also possible to try and compare different solutions and implement the best solution in the shortest time, greatly increasing the efficiency of exploring unknown fields.
When the code reaches thousands of lines, it is impossible to find problems by looking at each line of code, and it is beyond the capabilities of AI tools. Tools that present testing data results in a visual way like this can intuitively find abnormal areas and detect and correct problems early.
Starting the next step: Revised a problem once again and added some new functionalities. In this process, I have learned many valuable things. Next, I plan to add some advanced text processing functions based on this foundation. I also intend to incorporate a time element into the workflow control component. By combining these elements together, I will be able to quickly develop new and higher level features. https://fb.watch/mJmKsh3OTX/?mibextid=Nif5oz The function is very easy to use after completion.
Enhancing and exploring web and string handling capabilities through testing and analysis.
By using Popen+curl, it is easy to load files via the network. The same method can also be used to execute Python, LLama-CPP, or other powerful tools, easily unlocking all possibilities in the C language. It is best to first create all the features first and then improve them in use.
Continuing to add new features, you can transform and manipulate all data according to your ideas. When transforming to 256 colors, grayscale, or monochrome, the closest color to the original color is calculated with advanced contrast calculation algorithms, not by formula conversion. Additionally, you can also find the closest color name from the color code, and all features will be integrated with an AI model in the future to unlock even more possibilities.
#include "mylib.h"
const char *colorNames[256]={ "Black","Maroon","Green","Olive","Navy","Purple","Teal","Silver","Grey","Red","Lime","Yellow","Blue","Fuchsia","Aqua","White","Grey0","NavyBlue","DarkBlue","Blue3","Blue3","Blue1","DarkGreen","DeepSkyBlue4","DeepSkyBlue4","DeepSkyBlue4","DodgerBlue3","DodgerBlue2","Green4","SpringGreen4","Turquoise4","DeepSkyBlue3","DeepSkyBlue3","DodgerBlue1","Green3","SpringGreen3","DarkCyan","LightSeaGreen","DeepSkyBlue2","DeepSkyBlue1","Green3","SpringGreen3","SpringGreen2","Cyan3","DarkTurquoise","Turquoise2","Green1","SpringGreen2","SpringGreen1","MediumSpringGreen","Cyan2","Cyan1","DarkRed","DeepPink4","Purple4","Purple4","Purple3","BlueViolet","Orange4","Grey37","MediumPurple4","SlateBlue3","SlateBlue3","RoyalBlue1","Chartreuse4","DarkSeaGreen4","PaleTurquoise4","SteelBlue","SteelBlue3","CornflowerBlue","Chartreuse3","DarkSeaGreen4","CadetBlue","CadetBlue","SkyBlue3","SteelBlue1","Chartreuse3","PaleGreen3","SeaGreen3","Aquamarine3","MediumTurquoise","SteelBlue1","Chartreuse2","SeaGreen2","SeaGreen1","SeaGreen1","Aquamarine1","DarkSlateGray2","DarkRed","DeepPink4","DarkMagenta","DarkMagenta","DarkViolet","Purple","Orange4","LightPink4","Plum4","MediumPurple3","MediumPurple3","SlateBlue1","Yellow4","Wheat4","Grey53","LightSlateGrey","MediumPurple","LightSlateBlue","Yellow4","DarkOliveGreen3","DarkSeaGreen","LightSkyBlue3","LightSkyBlue3","SkyBlue2","Chartreuse2","DarkOliveGreen3","PaleGreen3","DarkSeaGreen3","DarkSlateGray3","SkyBlue1","Chartreuse1","LightGreen","LightGreen","PaleGreen1","Aquamarine1","DarkSlateGray1","Red3","DeepPink4","MediumVioletRed","Magenta3","DarkViolet","Purple","DarkOrange3","IndianRed","HotPink3","MediumOrchid3","MediumOrchid","MediumPurple2","DarkGoldenrod","LightSalmon3","RosyBrown","Grey63","MediumPurple2","MediumPurple1","Gold3","DarkKhaki","NavajoWhite3","Grey69","LightSteelBlue3","LightSteelBlue","Yellow3","DarkOliveGreen3","DarkSeaGreen3","DarkSeaGreen2","LightCyan3","LightSkyBlue1","GreenYellow","DarkOliveGreen2","PaleGreen1","DarkSeaGreen2","DarkSeaGreen1","PaleTurquoise1","Red3","DeepPink3","DeepPink3","Magenta3","Magenta3","Magenta2","DarkOrange3","IndianRed","HotPink3","HotPink2","Orchid","MediumOrchid1","Orange3","LightSalmon3","LightPink3","Pink3","Plum3","Violet","Gold3","LightGoldenrod3","Tan","MistyRose3","Thistle3","Plum2","Yellow3","Khaki3","LightGoldenrod2","LightYellow3","Grey84","LightSteelBlue1","Yellow2","DarkOliveGreen1","DarkOliveGreen1","DarkSeaGreen1","Honeydew2","LightCyan1","Red1","DeepPink2","DeepPink1","DeepPink1","Magenta2","Magenta1","OrangeRed1","IndianRed1","IndianRed1","HotPink","HotPink","MediumOrchid1","DarkOrange","Salmon1","LightCoral","PaleVioletRed1","Orchid2","Orchid1","Orange1","SandyBrown","LightSalmon1","LightPink1","Pink1","Plum1","Gold1","LightGoldenrod2","LightGoldenrod2","NavajoWhite1","MistyRose1","Thistle1","Yellow1","LightGoldenrod1","Khaki1","Wheat1","Cornsilk1","Grey100","Grey3","Grey7","Grey11","Grey15","Grey19","Grey23","Grey27","Grey30","Grey35","Grey39","Grey42","Grey46","Grey50","Grey54","Grey58","Grey62","Grey66","Grey70","Grey74","Grey78","Grey82","Grey85","Grey89","Grey93"};
const int colorMap[256][3] = { {0,0,0},{128,0,0},{0,128,0},{128,128,0},{0,0,128},{128,0,128},{0,128,128},{192,192,192},{128,128,128},{255,0,0},{0,255,0},{255,255,0},{0,0,255},{255,0,255},{0,255,255},{255,255,255},{0,0,0},{0,0,95},{0,0,135},{0,0,175},{0,0,215},{0,0,255},{0,95,0},{0,95,95},{0,95,135},{0,95,175},{0,95,215},{0,95,255},{0,135,0},{0,135,95},{0,135,135},{0,135,175},{0,135,215},{0,135,255},{0,175,0},{0,175,95},{0,175,135},{0,175,175},{0,175,215},{0,175,255},{0,215,0},{0,215,95},{0,215,135},{0,215,175},{0,215,215},{0,215,255},{0,255,0},{0,255,95},{0,255,135},{0,255,175},{0,255,215},{0,255,255},{95,0,0},{95,0,95},{95,0,135},{95,0,175},{95,0,215},{95,0,255},{95,95,0},{95,95,95},{95,95,135},{95,95,175},{95,95,215},{95,95,255},{95,135,0},{95,135,95},{95,135,135},{95,135,175},{95,135,215},{95,135,255},{95,175,0},{95,175,95},{95,175,135},{95,175,175},{95,175,215},{95,175,255},{95,215,0},{95,215,95},{95,215,135},{95,215,175},{95,215,215},{95,215,255},{95,255,0},{95,255,95},{95,255,135},{95,255,175},{95,255,215},{95,255,255},{135,0,0},{135,0,95},{135,0,135},{135,0,175},{135,0,215},{135,0,255},{135,95,0},{135,95,95},{135,95,135},{135,95,175},{135,95,215},{135,95,255},{135,135,0},{135,135,95},{135,135,135},{135,135,175},{135,135,215},{135,135,255},{135,175,0},{135,175,95},{135,175,135},{135,175,175},{135,175,215},{135,175,255},{135,215,0},{135,215,95},{135,215,135},{135,215,175},{135,215,215},{135,215,255},{135,255,0},{135,255,95},{135,255,135},{135,255,175},{135,255,215},{135,255,255},{175,0,0},{175,0,95},{175,0,135},{175,0,175},{175,0,215},{175,0,255},{175,95,0},{175,95,95},{175,95,135},{175,95,175},{175,95,215},{175,95,255},{175,135,0},{175,135,95},{175,135,135},{175,135,175},{175,135,215},{175,135,255},{175,175,0},{175,175,95},{175,175,135},{175,175,175},{175,175,215},{175,175,255},{175,215,0},{175,215,95},{175,215,135},{175,215,175},{175,215,215},{175,215,255},{175,255,0},{175,255,95},{175,255,135},{175,255,175},{175,255,215},{175,255,255},{215,0,0},{215,0,95},{215,0,135},{215,0,175},{215,0,215},{215,0,255},{215,95,0},{215,95,95},{215,95,135},{215,95,175},{215,95,215},{215,95,255},{215,135,0},{215,135,95},{215,135,135},{215,135,175},{215,135,215},{215,135,255},{215,175,0},{215,175,95},{215,175,135},{215,175,175},{215,175,215},{215,175,255},{215,215,0},{215,215,95},{215,215,135},{215,215,175},{215,215,215},{215,215,255},{215,255,0},{215,255,95},{215,255,135},{215,255,175},{215,255,215},{215,255,255},{255,0,0},{255,0,95},{255,0,135},{255,0,175},{255,0,215},{255,0,255},{255,95,0},{255,95,95},{255,95,135},{255,95,175},{255,95,215},{255,95,255},{255,135,0},{255,135,95},{255,135,135},{255,135,175},{255,135,215},{255,135,255},{255,175,0},{255,175,95},{255,175,135},{255,175,175},{255,175,215},{255,175,255},{255,215,0},{255,215,95},{255,215,135},{255,215,175},{255,215,215},{255,215,255},{255,255,0},{255,255,95},{255,255,135},{255,255,175},{255,255,215},{255,255,255},{8,8,8},{18,18,18},{28,28,28},{38,38,38},{48,48,48},{58,58,58},{68,68,68},{78,78,78},{88,88,88},{98,98,98},{108,108,108},{118,118,118},{128,128,128},{138,138,138},{148,148,148},{158,158,158},{168,168,168},{178,178,178},{188,188,188},{198,198,198},{208,208,208},{218,218,218},{228,228,228},{238,238,238}};
int main()
{ /*
Point2D p={NAN,NAN};
printf("%d\n",isnan(p.x));
char test[]="😁測試or tes測試😆";
printf("%d,%d\n",startsWith(test,"😁測試or "),endsWith(test,"測試😆"));
//return 0;
FILE *fRead;
char buffer[1024];
char url[500]="http://localhost:8000/static/std.js";
char uri[3024]="curl -s ";
strcat(uri,url);
printf("%d\n%s\n",startsWith(url,"http"),uri);
fRead=popen(uri, "r");
if (fRead == NULL) {
printf("Failed to open pipe\n");
}
else{while (fgets(buffer,1024, fRead)){
printf("%s",buffer);}
}
pclose(fRead);
//return 1;
*/
struct winsize size;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &size);
int x=size.ws_col/2;
printf("\n%d X %d\n",x,x);
Matrix matrix0=FromImage("http://localhost:8000/static/house.jpg").resize(x,x).toMatrix();
//Matrix matrix0=FromImage("https://live.staticflickr.com/848/42925979414_7e1627f1c8_b.jpg").resize(x,x).toMatrix();
matrix0.printMatrixC();
FromImage("http://localhost:8000/static/house.jpg").resize(x,x).toMatrixGray().printMatrixC();
FromImage("http://localhost:8000/static/house.jpg").resize(x,x).toMatrixR().printMatrixC();
FromImage("http://localhost:8000/static/house.jpg").resize(x,x).toMatrixG().printMatrixC();
FromImage("http://localhost:8000/static/house.jpg").resize(x,x).toMatrixB().printMatrixC();
matrix0.printMatrix();
Matrix matrix=FromImage("http://localhost:8000/static/icon.png").resize(x,x).toMatrix();
matrix.printMatrixC();
//return 1;
matrix.rotated(150,1.22,135,145).printMatrix();
Matrix matrix1=FromImage("http://localhost:8000/static/test1.jpg").resize(x,x).toMatrix();
matrix1.printMatrixC();
FromImage("http://localhost:8000/static/test1.jpg").resize(x,x).toMatrixGray().printMatrixC();
FromImage("http://localhost:8000/static/test1.jpg").resize(x,x).toMatrixR().printMatrixC();
FromImage("http://localhost:8000/static/test1.jpg").resize(x,x).toMatrixG().printMatrixC();
FromImage("http://localhost:8000/static/test1.jpg").resize(x,x).toMatrixB().printMatrixC();
matrix1.printMatrix();
Matrix matrix2=FromImage("http://localhost:8000/static/test.jpg").resize(x,x).toMatrix();
matrix2 .printMatrixC();
FromImage("http://localhost:8000/static/test.jpg").resize(x,x).toMatrixGray().printMatrixC();
FromImage("http://localhost:8000/static/test.jpg").resize(x,x).toMatrixR().printMatrixC();
FromImage("http://localhost:8000/static/test.jpg").resize(x,x).toMatrixG().printMatrixC();
FromImage("http://localhost:8000/static/test.jpg").resize(x,x).toMatrixB().printMatrixC();
matrix2.printMatrix();
return 0;
}
沒有留言:
發佈留言