I'm at my whits end... trying to get a custom list of pictures, a TImageList and a TListView to work together. Original problem: No dynamically-added pictures are displayed in the list. Narrowed it down, problem is in the TImagelist. Code is below. ilMain is the TImagelist (defined elsewhere). Adding a bitmap to the list, immediatly retrieving it, first "Draw" works fine but the sedond fails... what am I missing here?
var i:integer;
test:TSch;
currentimage :TBitmap;
stupid :TBitmap;
begin
currentImage:=TBitmap.Create;
stupid:=TBitmap.Create;
ilMain.Clear;
// currentImage.LoadFromFile('C:\Delphi\piccat\pics\MonaLisa.jpg');
JPeg2Bmp('C:\Delphi\piccat\pics\MonaLisa.jpg',currentImage);
form1.canvas.Draw(100,10,currentimage);
ilMain.Add(currentimage,nil);
ilMain.GetBitmap(0,stupid);
form1.canvas.Draw(200,10,stupid);
EDIT:
Done some further testing on this one; results are very confusing and inconsistent.
Result are actually GREATLY dependant on the size of the input file (thanks for that pointer, kobik!); it seems everything smaller than 256x256 isn't imported into the imagelist, while bigger pictures ALONG THE X-AXIS are (sometimes??) spread over several items.
ilMain was set to 256x256 pixels.
Here is the output for several input sizes (X x Y, in pixels): 950x414 First draw displays entire image, second take 256x256 pixels in the upper left corner. HOWEVER, THREE items of the TImagelist are populated, with 3x 256x256 pixels: the three pictures that can be "cut out" from the main picture and still be 256x256 pixels. All edges cut off which are smaller, either vertical or horizontal, than 256x256 are lost.
1600x1600 Six images are imported; the first row of complete 256x256 blocks which can be cut from the top of the pic. The incomplete block on the tp right is omitted, and all rows below Y-size 256 as well.
1500x1000 Similar to previous one; five items imported now.
638x376 Again similar; only two items "fit" now.
197x256 (my original test file, described in post above) NO ITEMS IMPORTED (X-size is smaller than TImaglist X-size?)
256x256 AGAIN, NO DATA IMPORTED
257x257 STILL NO DATA IMPORTED
260x260 STILL NO DATA IMPORTED
300x300 STILL NO DATA IMPORTED
512x256 Very weird one. One pic is imported; BUT it is reduced in size, so approximately 70% of the original pic fits in the (new) 256 X size. A black bar is added below the pic to make up for the lost space due to this shrinking.
So this is where I stop testing for now, and wondering if anyone can shed some light here...?
EDIT: Design part moved to new question (see request in comment kobik, thanks man!)