当前位置: 动力学知识库 > 问答 > 编程问答 >

Caml read file byte-by-byte issue

问题描述:

Hello,

I have a problem with an algorithm reading a file byte by byte. First, here's my code (for Caml lite) :

#open "graphics";;

type color == int;;

let rgb r g b =

r * 256 * 256 + g * 256 + b;;

open_graph "582x586+0-0";;

let couleurs chemin=

let canal=open_in_bin chemin in

let (largeur,hauteur)=(582,586) in

let b=ref 0 and v=ref 0 and r=ref 0 in

seek_in canal 54;

for i=0 to (largeur-1) do

for j=0 to (hauteur-1) do

b:=input_byte canal;

v:=input_byte canal;

r:=input_byte canal;

set_color (rgb !r !v !b);

plot (i) (j);

done

done;

close_in canal;;

couleurs "C:\Users\Anthony\Desktop\utsuho.bmp";;

Oh and sorry for all the French var names / function names :)

So basically, when I run couleurs to the picture located on my Desk, this is the result (expected rendering at left of image) :

Please, what's going wrong with it ? Why do I get that specific result ?

My final plan would be to convert images to a matrix of gray scale that I could work with.

分享给朋友:
您可能感兴趣的文章:
随机阅读: