Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 09-05-2006
mmx mmx is offline
Registrado
 
Registrado: may 2006
Posts: 2
Poder: 0
mmx Va por buen camino
de delphi a builder c++

Holas mi cuestion es si alguien me puede ayudar a pasar este codigo
a un objeto pero para c++ utilizo la version 6 de builder y ya e intentado el linkeado para pascal y no pasa nada no puedo usarla desde ya muchisimas gracias

Código Delphi [-]
unit spectrum; 
 
interface 
 
uses 
  Windows, Classes, Controls, Messages, Graphics; 
 
type 
  TSpectrumStyle = (ssSmooth, ssBlock); 
 
  TMiniSpectrum = class(TGraphicControl) 
  private 
    FGradient: TBitmap; 
    FBuffer: TBitmap; 
    FScale: Single; 
    FStyle: TSpectrumStyle; 
    FValues: array [0..127] of Single; 
    procedure SetStyle(const Value: TSpectrumStyle); 
  protected 
    procedure Paint; override; 
    procedure Resize; override; 
    procedure SetEnabled(Value: Boolean); override; 
  public 
    constructor Create(AOwner: TComponent); override; 
    destructor Destroy; override; 
    procedure Draw; 
  published 
    property Align; 
    property Scale: Single read FScale write FScale; 
    property Style: TSpectrumStyle read FStyle write SetStyle; 
    property OnClick; 
  end; 
 
implementation 
 
uses 
  fmod, fmodtypes; 
 
{ TMiniSpectrum } 
 
constructor TMiniSpectrum.Create(AOwner: TComponent); 
var 
  X, Y: Integer; 
  R, G, B: Integer; 
  C: TColor; 
begin 
  inherited; 
  Color := clBlack; 
  Width := 80; 
  Height := 32; 
  FScale := 4.0; 
  FStyle := ssSmooth; 
  Enabled := False; 
 
  // Create draw buffer 
  FBuffer := TBitmap.Create; 
  FBuffer.PixelFormat := pf32bit; 
  FBuffer.Width := Width; 
  FBuffer.Height := Height; 
 
  // Create gradient bitmap 
  FGradient := TBitmap.Create; 
  FGradient.PixelFormat := pf32bit; 
  FGradient.Width := 4; 
  FGradient.Height := 32; 
 
  R := 255; 
  G := 0; 
  B := 0; 
 
  for Y := 0 to 31 do 
  begin 
    if Y > 15 then 
      Dec(R, 16) 
    else 
      Inc(G, 16); 
    if R < 0 then 
      R := 0; 
    if G > 255 then 
      G := 255; 
    C := TColor(RGB(R, G, B)); 
    for X := 0 to 2 do 
      FGradient.Canvas.Pixels[X, Y] := C; 
    FGradient.Canvas.Pixels[3, Y] := TColor(0); 
  end; 
end; 
 
destructor TMiniSpectrum.Destroy; 
begin 
  FGradient.Free; 
  FBuffer.Free; 
  inherited; 
end; 
 
type 
  PSingleArray = ^TSingleArray; 
  TSingleArray = array [0..0] of Single; 
 
procedure TMiniSpectrum.Draw; 
var 
  Data: PSingleArray; 
  PeakData: Single; 
  W, X, Y: Integer; 
  ARect: TRect; 
begin 
  FBuffer.Canvas.Brush.Color := Color; 
  FBuffer.Canvas.FillRect(BoundsRect); 
 
  if Enabled then 
  begin 
    Data := PSingleArray(FSOUND_DSP_GetSpectrum); 
   //FSOUND_DSP_GetSpectrum es parte de una dll 
    // Get the peak value of each block of four values 
    for X := 0 to 127 do 
    begin 
      W := X * 4; 
      FValues[X] := Data^[W]; 
      if Data^[W + 1] > FValues[X] then 
        FValues[X] := Data^[W + 1]; 
      if Data^[W + 2] > FValues[X] then 
        FValues[X] := Data^[W + 2]; 
      if Data^[W + 3] > FValues[X] then 
        FValues[X] := Data^[W + 3]; 
      FValues[X] := FValues[X] * FScale; 
      if FValues[X] > 1.0 then 
        FValues[X] := 1.0; 
    end; 
 
    W := Width; 
    if W > 128 then 
      W := 128; 
 
    case FStyle of 
    ssSmooth: 
      begin 
        X := 0; 
        while X < W do 
        begin 
          if FValues[X] > 0.0 then 
          begin 
            Y := Height - Trunc(FValues[X] * 1.0 * Height); 
            FBuffer.Canvas.CopyRect(Rect(X, Y, X + 1, Height), FGradient.Canvas, Rect(0, Y, 1, FGradient.Height)); 
          end; 
          Inc(X); 
        end; 
      end; 
    ssBlock: 
      begin 
        // Sixteen values for every column 
        PeakData := 0; 
        X := 0; 
        while X < W do 
        begin 
          if PeakData < FValues[X] then 
            PeakData := FValues[X]; 
          if (X and 3 = 3) and (PeakData > 0.0) then 
          begin 
            Y := Height - Trunc(PeakData * 1.0 * Height); 
            PeakData := 0; 
            FBuffer.Canvas.CopyRect(Rect(X, Y, X + 4, Height), FGradient.Canvas, Rect(0, Y, 4, FGradient.Height)); 
          end; 
          Inc(X); 
        end; 
      end; 
    end; 
  end 
  else 
  begin 
    FBuffer.Canvas.Font.Color := clWhite; 
    ARect := BoundsRect; 
    DrawText(FBuffer.Canvas.Handle, 'Click for spectrum', -1, ARect, DT_WORDBREAK or DT_NOPREFIX or DT_VCENTER or DT_CENTER); 
  end; 
 
  // Copy the buffer to the control 
  Canvas.Draw(0, 0, FBuffer); 
end; 
 
procedure TMiniSpectrum.Paint; 
begin 
  Draw; 
end; 
 
procedure TMiniSpectrum.Resize; 
begin 
  inherited; 
  if Assigned(FBuffer) then 
  begin 
    FBuffer.Width := Width; 
    FBuffer.Height := Height; 
  end; 
end; 
 
procedure TMiniSpectrum.SetEnabled(Value: Boolean); 
begin 
  inherited; 
  FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit, Value); //parte de una dll 
end; 
 
procedure TMiniSpectrum.SetStyle(const Value: TSpectrumStyle); 
begin 
  if FStyle <> Value then 
  begin 
    FStyle := Value; 
    ZeroMemory(@FValues, SizeOf(FValues)); 
  end; 
end; 
 
end.

Última edición por dec fecha: 09-05-2006 a las 00:39:47.
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
C++ Builder vs Delphi mutant09 Varios 25 10-12-2007 17:05:31
Quien comprara Delphi y C++Builder? jhonny Debates 2 13-02-2006 04:56:19
report builder para delphi 6 karocs Impresión 1 11-06-2005 22:09:10
Parametros entre Delphi i c++ Builder jsb Varios 7 20-02-2004 18:25:05


La franja horaria es GMT +2. Ahora son las 07:09:55.


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