41223108 cp2023

  • Home
    • SMap
    • reveal
    • blog
  • About
  • 倉儲維護
    • s.cycu.org維護
    • windows維護
  • weekly progress
    • w1~4
    • w5
    • w6
    • w7
    • w9
    • w12
      • helloworld
      • GD繪圖程式1
    • W13
    • w15
  • ANSIC
    • 1.
    • 2.
    • 3.
    • 4.
    • 5.
    • 6.
    • 7.
    • 8.
    • 9.
    • 10.
  • NOTE
    • ssh
    • puttygen
  • 國旗練習
    • Thai
    • Laos
    • Bangladesh
    • vietnam
    • Italian
    • Russia
    • Belgium
    • Ukraine
    • Korea
  • 課程評分
  • Brython
  • setup
  • C_lib
  • replit
  • MSD
  • Final
vietnam << Previous Next >> Russia

Italian

#include <stdio.h>
#include <gd.h>

int main() {
    int width = 300;  // 宽度
    int height = 200; // 高度

    gdImagePtr image = gdImageCreateTrueColor(width, height);

    if (image == NULL) {
        printf("Failed to create image.\n");
        return 1;
    }

    // 确定颜色索引
    int green = gdImageColorAllocate(image, 0, 128, 0);
    int white = gdImageColorAllocate(image, 255, 255, 255);
    int red = gdImageColorAllocate(image, 255, 0, 0);

    // 填充颜色
    gdImageFilledRectangle(image, 0, 0, width / 3, height, green);
    gdImageFilledRectangle(image, width / 3, 0, (width / 3) * 2, height, white);
    gdImageFilledRectangle(image, (width / 3) * 2, 0, width, height, red);

    FILE *outputFile;
    outputFile = fopen("./../images/italian_flag.png", "wb");

    if (outputFile == NULL) {
        printf("Failed to open file for writing.\n");
        return 1;
    }

    gdImagePng(image, outputFile);
    fclose(outputFile);

    gdImageDestroy(image);

    return 0;
}


vietnam << Previous Next >> Russia

Copyright © All rights reserved | This template is made with by Colorlib