求gif(or jpg or bmp)转换为wbmp格式的代码(JAVA)(100分)

  • 主题发起人 主题发起人 clyin
  • 开始时间 开始时间
C

clyin

Unregistered / Unconfirmed
GUEST, unregistred user!
谢了!分不够可以再加。
 
clyin:如果你还要继续讨论请定期提前你的帖子,如果不想继续讨论请结束帖子。
请认真阅读大富翁论坛规则说明 http://www.delphibbs.com/delphibbs/rules.htm
 
pascal格式,自己去翻译吧。

Function SaveAsWBmpFile (Bmp:TBitmap; Filename:String): Boolean;
{ $Define bmp_already_is_black_and_white}
const
BorderWhite= 220*3;
BorderLight= 195 *3;
BorderLightGray= 160*3;
BorderGray=125*3;
BorderDarkGray=90*3;
BorderDark=60*3;
BorderBlack=30*2;
var F:File; Col:TColor;
Buf: Array[0..256] of Byte; (* maximum bitmap width = 256*8 pixels *)
Gray,BufLen,BPos,A,B,X,Y:Longint;
procedure Write_To_Header(L:Longint); var extra:Longint; b:Byte;
begin
extra:=0; While L>=128 do begin Inc(extra); Dec(l,128); end;
if extra>0 then begin b:=128+extra; BlockWrite(F,b,1); end;
b:=l; BlockWrite(F,b,1);
end;
begin
SaveAsWBmpFile:=False;
if Bmp=NIL then EXIT; if Bmp.Empty then EXIT;
if Bmp.Width=0 then EXIT; if Bmp.Height=0 then EXIT;
AssignFile(F,FileName);
Rewrite(F,1); if IOResult<>0 then EXIT;
BufLen:=Bmp.Width shr 3 + Byte(Bmp.Width and 7>0);
Write_To_Header(0); Write_To_Header(0);
Write_To_Header(Bmp.Width); Write_To_Header(Bmp.Height);
for Y:=0 to Bmp.Height-1
do begin
FillChar(Buf,SizeOf(Buf),0); BPos:=0; B:=128;
for X:=0 to Bmp.Width-1
do begin
{$IfDef bmp_already_is_black_and_white}
if Bmp.Canvas.Pixels[X,Y]<>clBlack then Inc(Buf[BPos],B);
{$Else}
Col:=Bmp.Canvas.Pixels[X,Y];
Gray:= (Col and $ff) + ((Col shr 8) and $ff) + ((Col shr 16) and $ff);
if (Gray>BorderWhite) then Inc(Buf[BPos],B) else
if (Gray>BorderLight)
then begin if (X mod 3<>0)or(Y mod 3<>1) then Inc(Buf[BPos],B) end else
if (Gray>BorderLightGray)
then begin if (X and 1=1)or(Y and 1=1) then Inc(Buf[BPos],B) end else
if (Gray>BorderGray)
then begin if (X and 1=1)=(Y and 1<>1) then Inc(Buf[BPos],B) end else
if (Gray>BorderDarkGray)
then begin if (X mod 3=1)and(Y mod 3=2) then Inc(Buf[BPos],B) end else
if (Gray>BorderDark)
then begin if (X and 3=0) and (Y and 3=0) then Inc(Buf[BPos],B) end else
if (Gray>BorderBlack)
then begin if (X mod 5=1) and (Y mod 5=3) then Inc(Buf[BPos],B) end;
{$EndIf}
if B>1 then B:=B shr 1 else begin B:=128; Inc(BPos); end;
end;
BlockWrite(F,Buf,BufLen);
end;
CloseFile(F);
SaveAsWBmpFile:=True;
end;
 
wbmp是什么格式,和bmp有什么区别?
 
你到底是想干什么,delphi有控件gifimage支持gif,还要bmp干什么,实在搞不懂你。?
 
wbmp是一种wpa协议的格式的图形
说的白一点就是手机上的logo
 
已经找到了Java的转换程序
 
后退
顶部