Fórum Rotacionar Imagem #265333
14/01/2005
0
Ja tentei de tudo pra resolver, mas nao funciona.
Alguem pode me ajudar?
procedure TImg.RotateBMP(Angle: Real); var ang,cos_angle,sin_angle: Double; newWidth,newHeight,nWidth,nHeight, x,y,newX,newY,oldX,oldY: Integer; p1,p2,p3,p4,newP1,newP2,newP3,newP4, leftTop, rightTop, leftBottom, rightBottom: TPoint; NovoBmp: TBitmap; begin ang := -(angle* Pi)/180; nWidth := m_nWidth; nHeight := m_nHeight; cos_angle := cos(ang); sin_angle := sin(ang); // Calculate the size of the new bitmap p1 := Point(0,0); p2 := Point(nWidth,0); p3 := Point(0,nHeight); p4 := Point(nWidth-1,nHeight); newP1.x := p1.x; newP1.y := p1.y; newP2.x := round(p2.x*cos_angle - p2.y*sin_angle); newP2.y := round(p2.x*sin_angle + p2.y*cos_angle); newP3.x := round(p3.x*cos_angle - p3.y*sin_angle); newP3.y := round(p3.x*sin_angle + p3.y*cos_angle); newP4.x := round(p4.x*cos_angle - p4.y*sin_angle); newP4.y := round(p4.x*sin_angle + p4.y*cos_angle); leftTop.x := min(min(newP1.x,newP2.x),min(newP3.x,newP4.x)); leftTop.y := min(min(newP1.y,newP2.y),min(newP3.y,newP4.y)); rightBottom.x := max(max(newP1.x,newP2.x),max(newP3.x,newP4.x)); rightBottom.y := max(max(newP1.y,newP2.y),max(newP3.y,newP4.y)); leftBottom.x := leftTop.x; leftBottom.y := 2+rightBottom.y; rightTop.x := 2+rightBottom.x; rightTop.y := leftTop.y; newWidth := rightTop.x - leftTop.x; newHeight := leftBottom.y - leftTop.y; //NovoBmp NovoBmp := TBitmap.Create; NovoBmp.Width := newWidth; NovoBmp.Height := newHeight; NovoBmp.Canvas.FillRect(Rect(0,0,NewWidth,NewHeight)); //imgDest.Create(newWidth,newHeight,GetBpp(),GetType()); //imgDest.SetPalette(GetPalette()); newY := 0; for y := leftTop.y to leftBottom.y do begin //info.nProgress = (long)(100*newY/newHeight); //if (info.nEscape) break; newX := 0; for x := leftTop.x to rightTop.x do begin oldX := round(x*cos_angle + y*sin_angle - 0.5); oldY := round(y*cos_angle - x*sin_angle - 0.5); if ( oldX >= 0 ) and ( oldX < m_nWidth ) and ( oldY >= 0 ) and ( oldY < m_nHeight ) then NovoBmp.Canvas.Pixels[newX,newY] := Canvas.Pixels[oldX,oldY] else NovoBmp.Canvas.Pixels[newX,newY] := clWhite; inc(newX); end; inc(newY); end; //select the destination Picture.Bitmap := NovoBmp; m_nWidth := newWidth; m_nHeight := newHeight; Width := newWidth; Height := newHeight; NovoBmp.Free; end;
Gabriela
Curtir tópico
+ 0Posts
14/01/2005
Massuda
//select the destination Picture.Bitmap := NovoBmp;
//select the destination Picture.Bitmap.Assign(NovoBmp);
Gostei + 0
18/01/2005
Gabriela
Estou usando um outro codigo tb, que é bem mais rapido, pois usa scanline, mas continuo com o mesmo problema.
Não sei mais o que fazer.
Gostei + 0
18/01/2005
Massuda
Dei uma pesquisada sobre a mensagem de erro que você citou... talvez não tenha relação alguma, mas [url=http://support.microsoft.com/?id=177078]este artigo do KB da Microsoft[/url] indica que o problema que você está encontrando pode ser causado pelo Norton AntiVirus.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)