coldboy
asked on
problem with picture format
I want to stretch picture and save it by BMP format (to add into a Imagelist). If the source picture contain a bitmap, this code work correctly:
Procedure Newpicture(Source:Tpicture ;Var DesBMP:Tbitmap;newW,newH:i nteger);
var i,j:integer;
begin
DesBMP.width:=newW;
DesBMP.height:=newH;
For i:=0 to newW-1 do
for j:=0 to newH-1 do
with Source.bitmap do
DesBMP.canvas.pixels[i,j]: =Canvas.pi xel[i*widt h div newW,j*height div newH];
end;
But the problem come with me if source picture contain a Metal Image or a JPEG Image. If JPEGImage, I can use SaveToClipboardFormat and then use tmpBMP(another Tbitmap).LoadFromClipboard Format and continue use the code above. But metal image is not! I think, there is simple code (maybe you know but I don't know) can solve my problem. I need yours' helping!
Procedure Newpicture(Source:Tpicture
var i,j:integer;
begin
DesBMP.width:=newW;
DesBMP.height:=newH;
For i:=0 to newW-1 do
for j:=0 to newH-1 do
with Source.bitmap do
DesBMP.canvas.pixels[i,j]:
end;
But the problem come with me if source picture contain a Metal Image or a JPEG Image. If JPEGImage, I can use SaveToClipboardFormat and then use tmpBMP(another Tbitmap).LoadFromClipboard
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm testing your answer...
ASKER
Excellent! But can you show me why I can do by that way? (or how Strechdraw work?)
I don't know how it works. I just knows it works. :-) And a bit faster than when you yourself go walking through the bitmap, pixel by pixel, as you tried to do.
I'm not an expert at handling graphical formats but I do know that using the Pixel property will slow down your application enormously. There are faster techniques for this but I just don't know them. (Something with scanlines and things like that.)
I'm not an expert at handling graphical formats but I do know that using the Pixel property will slow down your application enormously. There are faster techniques for this but I just don't know them. (Something with scanlines and things like that.)
DesBMP.Canvas.Draw(0,0,Sou
???