0

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);
Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
Wawan Ma-chun
  • 115
  • 3
  • 15

2 Answers2

0

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.

Qsebas
  • 458
  • 3
  • 15
  • is there any other way to do what i wanted without change in hardware? – Wawan Ma-chun May 29 '13 at 08:59
  • As I've suggested, resizing the memory bitmap to something more equivalent to a normal screen resolution, for example if you have a 1.000.000 pixels image (width) but you will show it in a form, as a tipical screen has no more than 2.000 pixels with, it should be better to rescale the image to a 2.000 pixel image and have that in memory – Qsebas May 29 '13 at 21:39
0

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;
Joseph Poirier
  • 386
  • 2
  • 17
  • I didn't realize the 8-byte option for LongInt only applied to 64-bit iOS, which also means FMX framework. thx for pointing that out. – Joseph Poirier Jan 18 '17 at 18:06