Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 20-06-2008
Avatar de cHackAll
[cHackAll] cHackAll is offline
Baneado?
 
Registrado: oct 2006
Posts: 2.159
Poder: 20
cHackAll Va por buen camino
Vista la necesidad he convertido el anterior code a BCB, disfrútenlo;

Código:
#include <math.h>
#include <math.hpp>

// ...

Graphics::TBitmap *Rotate(TCanvas *Source, int Width, int Height, int Angle, bool Reverse)
{
 Double Radio = sqrt(pow(Width / 2, 2) + pow(Height / 2, 2)), AngleRad = (360 - (Angle % 360)) * M_PI / 180;
 TPoint Points[3] = {Point(Width, -Height), Point(Width, Height), Point(Width, Height)};
 for (int Index = 0; Index < 3; Index++)
 {
  Double Angle = ArcTan2(Points[Index].y, Points[Index].x) + AngleRad + ((Index % 2)? 0 : M_PI);
  Points[Index] = Point(RoundTo((cos(Angle) * Radio) + Radio, 0), RoundTo(Radio - (sin(Angle) * Radio), 0));
 }

 Graphics::TBitmap *Result = new Graphics::TBitmap();
 Result->Canvas->Brush->Color = clFuchsia;
 Result->TransparentColor = clFuchsia;
 int Size = RoundTo(Radio * 2, 0);
 Result->Height = Size;
 Result->Width = Size;

 PlgBlt(Result->Canvas->Handle, Points, Source->Handle, 0, 0, Width, Height, 0, 0, 0);
 if (Reverse) Result->Canvas->CopyRect(Rect(0, 0, Size, Size), Result->Canvas, Rect(Size - 1, 0, 0, Size));
 return Result;
}
Modo de uso:

Código:
void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{
 ImageHolder->Picture->Assign(Image1->Picture);
 Graphics::TBitmap *Bitmap = Rotate(ImageHolder->Canvas, ImageHolder->Width, ImageHolder->Height, TrackBar1->Position, CheckBox1->Checked);
 ImageHolder->Picture->Assign(Bitmap);
 Bitmap->Free();
}
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 17:57:22.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi