3
3wccdel
Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手,我看了98年10月已结束讨论的问题“Tbitmap初始化”,我乃DELPHI低手,用了
几幅JPG图,好象显示的东东都一样,分数不多,请高手不吝赐教。代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var x,y : integer;
BitMap : TBitMap;
lplogpalMaxLogPalette;//pointer of TMaxLogPalette
pByteArray;
Jpg:TJpegImage;
begin
//By Hgubegin
Jpg:=TJpegImage.Create;
// By Hgu
Jpg.LoadfromFile('4.jpg');
//24Bit JPG By Hgu
BitMap := TBitMap.create;
Bitmap.Width:=256;
Bitmap.Height:=256;
Bitmap.PixelFormat:= pf8bit;
GetMem(lpLogPal,sizeof(TLOGPALETTE) + ((255) * sizeof(TPALETTEENTRY)));
lpLogPal.palVersion := $0300;
lpLogPal.palNumEntries := 256;
for x := 0 to 255do
begin
lpLogPal.palPalEntry[x].peRed := x;//没问题了!
lpLogPal.palPalEntry[x].peGreen := x;
lpLogPal.palPalEntry[x].peBlue := x;
end;
Bitmap.Palette := CreatePalette(pLogPalette(lpLogPal)^);//要转换
FreeMem(lpLogPal,sizeof(TLOGPALETTE) + ((255) * sizeof(TPALETTEENTRY)));
for y := 0 to BitMap.Height -1do
begin
P := BitMap.ScanLine[y];
for x := 0 to BitMap.Width -1do
P[x] := Byte(x*y);//这里不类型转换一下也会Range Checking错
end;
canvas.draw(0,0,BitMap);//form.canvas, just for a lookend;
end;
几幅JPG图,好象显示的东东都一样,分数不多,请高手不吝赐教。代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var x,y : integer;
BitMap : TBitMap;
lplogpalMaxLogPalette;//pointer of TMaxLogPalette
pByteArray;
Jpg:TJpegImage;
begin
//By Hgubegin
Jpg:=TJpegImage.Create;
// By Hgu
Jpg.LoadfromFile('4.jpg');
//24Bit JPG By Hgu
BitMap := TBitMap.create;
Bitmap.Width:=256;
Bitmap.Height:=256;
Bitmap.PixelFormat:= pf8bit;
GetMem(lpLogPal,sizeof(TLOGPALETTE) + ((255) * sizeof(TPALETTEENTRY)));
lpLogPal.palVersion := $0300;
lpLogPal.palNumEntries := 256;
for x := 0 to 255do
begin
lpLogPal.palPalEntry[x].peRed := x;//没问题了!
lpLogPal.palPalEntry[x].peGreen := x;
lpLogPal.palPalEntry[x].peBlue := x;
end;
Bitmap.Palette := CreatePalette(pLogPalette(lpLogPal)^);//要转换
FreeMem(lpLogPal,sizeof(TLOGPALETTE) + ((255) * sizeof(TPALETTEENTRY)));
for y := 0 to BitMap.Height -1do
begin
P := BitMap.ScanLine[y];
for x := 0 to BitMap.Width -1do
P[x] := Byte(x*y);//这里不类型转换一下也会Range Checking错
end;
canvas.draw(0,0,BitMap);//form.canvas, just for a lookend;
end;