㈠ 怎麼用c語言讀取gif圖片內容文件
分類: 電腦/網路 >> 程序設計 >> 其他編程語言
問題描述:
怎麼用C語言讀取賀拆備gif圖片內容文件 假如文件中有6個gif圖片,只讀取第一個圖片;讀完後寫入一個空文件中
解析:
用二進制文件方法打開。
(1)讀gif_id,輸出gif_id, 6 bytes
(2)讀logical_screen_descriptor(結構),並輸出
(3)如果 ScrHd.flag_GC_table == 1,
則有全局色表,則讀全局色表,並輸出
(4)循環,
檢查gif塊的類御賣型,按塊的類型讀塊,並輸出
若:
case: 0x2c -- 它是,Image Descriptor(結構),讀塊並輸出
判斷有無色表,有則讀塊並輸出,
下面 1 byte 表示 lZW min Code Size,讀並輸出
子塊 (include size, bytes*size data) 讀塊並輸出
子塊 (include size, bytes*size data) 讀塊並輸出
可能有很多子塊,讀塊並輸出
直到 0x00 讀塊並輸出,
break;
若case: 0x21 0xf9 -- 控制塊,讀到 0x00, 並輸出
break;
若case: 0x21 0xFe -- 註解塊,讀到 0x00,並輸出
break;
若case: 0x21 0x01 -- 普通禪毀文本塊,讀到 0x00,並輸出
break;
若case: 0x21 0xff -- 應用程序塊,讀到 0x00,並輸出
break;
若case: 0x3B -- END 第一個圖片完畢的標識,並輸出
break;
default: 列印「文件錯誤」break;
(5)關閉文件。
㈡ C語言設計一個簡單的圖形動畫,用turboc2運行,怎樣編寫使圖形動起來的代碼
1、首先,打開vc6.0,建立程序編寫頁面,建立C語言環境,聲明兩個整數型變數。
㈢ c語言中如何輸出圖像
lz需要弄清楚,你要輸出什麼格式的圖像,bmp,JPG。。。不同格式的圖像的數據內部結構是不一樣的,弄清楚不同格式圖片的數據結構組成,直接採用相應地演算法,用C語言文件輸出函數(fopen,fprintf……那幾個函數,具體我也忘了怎麼用了)將數據點寫入文件就行了。
㈣ 用C語言編寫程序,輸出如下圖形.要求:程序必須能夠根據輸入的層數動態輸出相應的圖形
#include<宴和stdio.h>
int main()
{int n,i,j;
printf("請輸入層數:");
scanf("%d",&蘆祥中n);
for(i=0;i<n;i++)
{for(j=0;j<n-i;j++)
printf(" ");
for(j=0;j<2*i+1;j++)
printf("%d ",2*i+1);
printf("陪山 ");
}
return 0;
}
㈤ C語言中如何輸出圖形
你可以採用循環的方法來做,需要輸出A的位置的時候就輸出A,其他地方就輸出空格,就行了
#include<stdio.h>
voidmain()
{
inti,j,n;
printf("請輸入要輸出幾行: ");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=0;j<n-i;j++)//每行前的空格控制
printf("");
for(intk=0;k<=2*i-1;k++)輸出字母
{
if(k==0||k==2*i-2)輸出A
printf("A");
else
printf("");
}
printf(" ");//換行
}
}
㈥ 如何用c語言以二進制流的方式讀取並顯示gif文件
二進制打開文談棗件fopen(filename,"rd")
二進制讀可以用 fscanf()
#include <啟老stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
FILE * fp;
char * filename = "悄侍升test.dat";
int i;
char str[128];
if( (fp=fopen(filename,"rb"))== NULL )
{
㈦ 有人知道如何用C/C++/C#將.GIF格式的圖片讀取並且顯示出來
c#picture可以直接顯示gif
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace WindowsApplication1
{
/// <summary>
/// Form8 的摘要說明。
/// </summary>
public class animateImage : System.Windows.Forms.Form
{
/// <summary>
/// 必需的設計器變數。
/// </summary>
private System.ComponentModel.Container components = null;
Bitmap animatedImage = new Bitmap("1.gif");
bool currentlyAnimating = false;
public animateImage()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
// TODO: 在中差斗 InitializeComponent 調用後添加任何構造函數代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯賣磨器慶差修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
//
// Form8
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(536, 438);
this.Name = "Form8";
this.Text = "Form8";
this.Load += new System.EventHandler(this.Form8_Load);
}
#endregion
// [STAThread]
// static void Main()
// {
// Application.Run(new Form2());
// }
private void Form8_Load(object sender, System.EventArgs e)
{
//This method begins the animation.
}
public void AnimateImage()
{
if (!currentlyAnimating)
{
//Begin the animation only once.
ImageAnimator.Animate(animatedImage, new EventHandler(this.OnFrameChanged));
currentlyAnimating = true;
}
}
private void OnFrameChanged(object o, EventArgs e)
{
//Force a call to the Paint event handler.
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
this.SetStyle(ControlStyles.DoubleBuffer,true);
//Begin the animation.
AnimateImage();
//Get the next frame ready for rendering.
ImageAnimator.UpdateFrames();
//Draw the next frame in the animation.
e.Graphics.DrawImage(this.animatedImage, new Point(0, 0));
e.Graphics.DrawString("哈哈",new Font("Tahoma",12),new SolidBrush(Color.Red),10,10);
}
// public static void Main()
// {
// Application.Run(new animateImage());
// }
}
}
㈧ 用C語言編寫的CGI如何輸出圖像文件
要制定輸出廳姿的是圖形,需要輸出http數據的扮型絕頭部指租鋒示的。而不是默認的plant/text這樣的
㈨ c語言如何輸出圖案
在C語言中要輸出一個圖案還是比較方便的,主要要看清楚它是由多少行組成的,然後外循環就循環多少次。在每一次的外循環中完成一行的輸出,這時要看清楚他有沒有幾個空格,然後再輸出指定的若干個字元。等到這一行輸出完成以後就換行。