0
votes

My code -> displaying waveform stereo .wav file

max_l and max_r here is the highest value of the waveform in each channel.

 form2:= TForm2.Create(self);
 form2.Image1.Visible := true;
 form2.Image1.Width := numsamples;
 form2.Image1.Height := max_l * 2;
 form2.Image1.Canvas.Lock;
 form2.Image1.Canvas.MoveTo(0,mid);
 form2.Image1.Canvas.Pen.Color := clRed
 form2.Image2.Visible := true;
 form2.Image2.Width := numsamples;
 form2.Image2.Height := max_r * 2;
 form2.Image2.Canvas.Lock;
 form2.Image2.Canvas.MoveTo(0,mid);
 form2.Image2.Canvas.Pen.Color := clRed
 x:=0;
    for i := 0 to numchannels do begin
      if i mod 2 = 0 then begin
      form2.Image2.Canvas.MoveTo(x,max_r);
      form2.Image2.Canvas.LineTo(x,max_r+buff[i]);
      x:=x+1;
      end
      else begin
      form2.Image1.Canvas.MoveTo(x,max_l);
      form2.Image1.Canvas.LineTo(x,max_l+buff[i]);
      end;
    end;

I want to know how much is max for TImage Delphi max height and width? Because i'm trying to draw a big picture of entire waveform of a .wav file. For example now i got image1.height = 23000 more and get EOutOfResource issue or maybe my code got mistake in it?. Any suggestion would be appreciated thanks.

EDIT1 : also i tried to use draw bmp then resize it with stretchdraw method but it doesnt work too, here is my code and the main idea is first i draw the super big original size into bmp, then shrink it using StretchDraw Function then draw it on TImage. But still bitmap also return me the same issue EOutOfResources.

 form2:= TForm2.Create(self);
 form2.Image1.Visible := true;
 bmp:=TBitmap.Create;
 bmp.Height:=max_l*2;
 bmp.Width:=numsamples;
 bmp.Canvas.Pen.Color:=clRed;
 bmp.Canvas.MoveTo(0,max_l);
 x:=0;
    for i := 0 to numchannels do begin
      if i mod 2 = 0 then begin
      bmp.Canvas.MoveTo(x,max_r);
      bmp.Canvas.LineTo(x,max_r+buff[i]);
      x:=x+1;
      end;
    end;
newwidth:=1000;
newheight:=500;
bmp.Canvas.StretchDraw(rect(0,0,newheight,newwidth),bmp);
form2.Image1.Canvas.Draw(0,0,bmp);
2

2 Answers

0
votes

It depends on your installed and available memory (beside other factors as the OS version (seven is better), the OS edition (64 bits is better), the number of bitmaps already allocated).

If you are experienting this problem and cannot be solved with more hardware, you should tile the image in several sub images, and resize the output to something more equivalent to a standard monitor resolution.

0
votes

Throw the TImage component in a TScrollBox and set the AutoSize option in the TImage, and use [MaxInt] to fetch the maximum value for your Integer.

Image1.AutoSize := true;

was pointed to [AutoSize] issue in a large file I was trying to display when I was playing around with this project.. https://community.embarcadero.com/blogs/entry/converting-to-grayscale-with-tbitmapscanline-property-39051

MaxInt example from.. https://community.embarcadero.com/blogs/entry/converting-to-grayscale-with-tbitmapscanline-property-39051 - [uBitmapUtils.pas]

TBGR32 = packed record
  B, G, R, A: Byte;
end;
TBGR32Array = packed array[0..MaxInt div SizeOf(TBGR32)-1] of TBGR32;
PBGR32Array = ^TBGR32Array;