Since you are not getting an error when loading the JPEG image, I suspect the problem may be in the conversion from TJPEGImage to TBitmap. Unless you are going to be manipulating the image pixels, you don't need the conversion at all, you can assign the original TJPEGImage directly to the TImage. The VCL's TPicture class uses derived TGraphic classes so it can display images in their native formats, you should utilize that feature, eg:
procedure TForm1.btnBrowseClick(Sender: TObject);
OpenPicturedialog1.InitialDir := FindImageFolder(true);
if OpenPictureDialog1.Execute then
if Image1.Picture.Graphic is TJPEGImage then
if TJPEGImage(Image1.Picture.Graphic).Grayscale then
jpg := TJPEGImage.Create;
jpg.Grayscale := True;
bmp := TBitmap.Create;
bmp.PixelFormat := pf32bit;
Update: I did some tests in XE2 on Windows 7, and saw the same issue you do.
If I load the JPGs as-is using TImage.Picture.LoadFromFile(), they display fine only if the TImage.Stretch or TImage.Proportional property is True. If they are both set to False (the default), the images display blank.
If I load the JPGs into TJPEGImage first and then assign that to TBitmap, the conversion itself works fine (proved by saving the TBitmap to a .bmp file), and the bitmaps are displayed fine only if Stretch or Proportional are True, otherwise they display blank.
So, as another test, I tried using TPaintBox, drawing the images manually in its OnPaint event. If I use TCanvas.Draw() to draw the images as-is in their full dimensions, they display empty. If I use TCanvas.StretchDraw() to fit the images within the `PaintBox's client area, they display fine.
So, I think TCanvas is likely running into memory issues trying to display images at such larger dimensions. It has nothing to do with the particular type of JPGs being used (which are being loaded fine).
Update: nevermind what I said above. I see that the provided JPGs just have really large DPIs and happen to all be white in their top-left corners. If the TImage/TPaintBox is sized large to compensate, I can now see the images in their full dimensions (it is easier to see if the TImage is placed on a TScrollBox with TImage.AutoSize set to True). That would explain why stretch/proportional drawing works, by stretching the images to match TImage's dimensions when needed.
Hi Remy... I was doing that first and it was doing the same thing, only on some pictures. So I retested that to verify, still blank. Pushed out zipped folder of the three images to a download folder for testing. I moved this code line, [ Image1.Picture.LoadFromFile(name);], right to the top inside the try code and removed the [Image1.Picture.Assign(bmp)] to retest it.
I saw your comment from this post earlier [stackoverflow.com/questions/22291162/ and I wondered if there was a formatting change for sRGB vs. regular RGB files as there is in 24-bit vs. 32-bit files. If there is that and it isn't covered in the component or JPEG file, I could see where it would just display blank.
thx for the update, I tried the stretchDraw and scrollbox earlier, but I may have missed the Autosize option. I'll give that a go.
AutoSize is off by default. Only needed to check that option in the form image component and it worked as expected. Thx so much. Tomorrow, I'm going to rollin' the newer grayscale routine I was testing today, and our software rev will be complete. I can't believe I missed that checkbox. ps. .Assign(bmp) works as well as .Picture.LoadFromFile(name) with the checkbox set to [True]