編譯我決定學習C,我儘量按照這個教程http://ricardolovelace.com/creating-bitmap-images-with-c-on-windows.html如何在C創建位圖,並用gcc
,但是當我嘗試編譯我的代碼用gcc,因爲這> GCC -Wall TESTCØ應用
他不知道type_rgb,我可以定義這種類型,以及如何?和我的代碼在哪裏?
#include <stdio.h>
struct rgb_data {
float r, g, b;
};
void save_bitmap(const char *file_name, int width, int height, int dpi, type_rgb *pixel_data);
/*
next steps of the tutorial
*/
rgb_data *pixels = new rgb_data[width * height];
for(int x = 0; x < width; x++)
{
for(int y = 0; y < height; y++)
int a = y * width +x;
{
if ((x > 50 && x < 350) && (y > y && y < 350))
{
pixels[a].r = 255;
pixels[a].g = 255;
pixels[a].b = 0;
}else{
pixels[a].r = 55;
pixels[a].g = 55;
pixels[a].b = 55;
}
}
}
save_bitmap("black_border.bmp", width, height, dpi, pixels);
你的類型爲'結構rgb_data',考慮使結構聲明一正確的typedef。 – orhtej2
當你說'> gcc -Wall testc o app',你是不是指'> gcc -Wall test.c -o app'?如果是這樣,那麼你運行該應用程序爲'。/ app'。 –
C沒有'new'。我認爲你在混合一點C++。 –