Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 05-07-2008
Avatar de cHackAll
[cHackAll] cHackAll is offline
Baneado?
 
Registrado: oct 2006
Posts: 2.159
Poder: 22
cHackAll Va por buen camino
Es un poco dificil ayudar cuando no se "tiene" el código completo; "undeclared identifier; pRGBTripleArray" !!! y bueno tambien vale la pena comentar el mismo problema acerca de las variables globales!

Eh aqui una posible solucion... tiene alguna falla pero no la puedo probar con el "original", por lo anteriormente comentado!

Código Delphi [-]
function GetHistogram(Image: TImage; UseMax: LongBool = True): TBitmap;
type
 RGBStruct = packed record
  b, g, r: byte;
 end;
var
 Color: ^RGBStruct;
 Count, Max: Cardinal;
 Index, Position, r, g, b: Byte;
 Histogram: array [0..255] of record
  r, g, b: Cardinal;
 end;
 Value: TColor;
begin
 Max := 0;
 Result := TBitmap.Create;
 Result.Assign(Image.Picture.Graphic);
 Result.PixelFormat := pf24bit;
 Count := Result.Width * Result.Height;
 Color := Result.ScanLine[Result.Height - 1];
 FillChar(Histogram, SizeOf(Histogram), 0);
 while LongBool(Count) do
  begin
   Inc(Histogram[Color.r].r);
   Inc(Histogram[Color.g].g);
   Inc(Histogram[Color.b].b);
   if UseMax then
    begin
     if Color.r > Max then Max := Color.r;
     if Color.g > Max then Max := Color.g;
     if Color.b > Max then Max := Color.b;
    end;
   Inc(Color);
   Dec(Count);
  end;
 Result.Width := 256;
 Result.Height := 256;
 if not UseMax then Inc(Max);
 for Index := 0 to 255 do
  begin
   Histogram[Index].r := (Histogram[Index].r * 100) div Max;
   Histogram[Index].g := (Histogram[Index].g * 100) div Max;
   Histogram[Index].b := (Histogram[Index].b * 100) div Max;
   for Position := 0 to 255 do
    begin
     r := Byte(Position <= Histogram[Index].r) * 255;
     g := Byte(Position <= Histogram[Index].g) * 255;
     b := Byte(Position <= Histogram[Index].b) * 255;
     if (r > 0) and (g > 0) and (b > 0) then
      Value := RGB(r, g, b)
     else
      Value := clGray shr 1;
     Result.Canvas.Pixels[Index, Position] := Value;
    end;
  end;
end;

Toma una atencion principal en la cantidad de bucles; y en el uso del ScanLine.

Un Saludo
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
Histograma en Delphi Cesar Junior Gráficos 10 05-07-2012 12:36:42
Histograma. Obtener máximos y mínimos relativos Delphius Varios 7 16-04-2007 12:12:46
Histograma javikanin Varios 16 02-01-2006 23:40:17
Graph Meter (histograma) cadena Gráficos 0 01-12-2004 19:29:23


La franja horaria es GMT +2. Ahora son las 12:58:00.


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