Jump to content

AlexBelo

Members
  • Content Count

    31
  • Joined

  • Last visited

Community Reputation

10 Good

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. AlexBelo

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    AFAIR, there was QC (old borland quality control system) report about 16bit API calls in VCL (in some components if memory serves).
  2. AlexBelo

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    > I don't know why you would prefer DDB when you're working with bitmaps that large. Use DIBs instead. They are backed by virtual memory. Exactly by reason of "my" virtual memory: DDB resides somewhere in GDI (out of my process); I simply has no memory to hold bmp data in my memory during subsequent operations. OK, further investigations have more academical interest because workaround (manual call of StretchBlt) is already found ...
  3. AlexBelo

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    I've found the only related question (without answer) GDI+ Bitmap size limitation? (December 1st, 2006) https://forums.codeguru.com/showthread.php?407837-GDI-Bitmap-size-limitation Also I've noticed that if I comment out Image->Picture->Bitmap->PixelFormat=pfDevice; the problem exists only when initial bmp has pfDevice or pf32bit (the same as pfDevice, AFAIUI) format. Upd: CDC Class (MFC, not very relevant, but ...) https://docs.microsoft.com/en-us/cpp/mfc/reference/cdc-class?view=msvc-160
  4. AlexBelo

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    void TForm1::AdjImage(bool stretch) { if(stretch) { ScrollBox->VertScrollBar->Visible=false; ScrollBox->HorzScrollBar->Visible=false; Image->AutoSize=false; Image->Width=ScrollBox->ClientWidth; Image->Height=ScrollBox->ClientHeight; Image->Stretch=true; } else { Image->Stretch=false; Image->AutoSize=true; ScrollBox->VertScrollBar->Visible=true; ScrollBox->HorzScrollBar->Visible=true; } } void __fastcall TForm1::btnCreateBmpClick(TObject *Sender) { AdjImage(cbStretch->Checked); // preparing Image according to desired view unsigned int w=seW->AsInteger; // test dimensions unsigned int h=seH->AsInteger; TPixelFormat pf; if(rbDevice->Checked) pf=pfDevice; else if(rb8bit->Checked) pf=pf8bit; else if(rb24bit->Checked) pf=pf24bit; else pf=pf32bit; TcppBitmap bmp; bmp->PixelFormat=pf; bmp->SetSize(w, h); TColor c; if(pf!=pf8bit) c=clRed; else c=clBlack; bmp->Canvas->Pen->Color=c; // some testing draw bmp->Canvas->Pen->Width=10; bmp->Canvas->MoveTo(5, 0); bmp->Canvas->LineTo(5, h); bmp->Canvas->MoveTo(0, 0); bmp->Canvas->LineTo(w, h); bmp->Canvas->Pen->Width=1; bmp->Canvas->MoveTo(0, 0); bmp->Canvas->LineTo(w, 0); bmp->Canvas->LineTo(w-1, 0); bmp->Canvas->LineTo(w-1, h-1); bmp->Canvas->LineTo(0, h-1); bmp->Canvas->LineTo(0, 0); Image->Picture->Assign(bmp); // show in Image Image->Picture->Bitmap->PixelFormat=pfDevice; // "move into GDI domain" (out of application's memory space) Image->Picture->Bitmap->FreeImage(); // deallocate DIB-section (if initial bmp was not pfDevice) if(pf!=pf8bit) c=clGreen; else c=clGray; // another test (on Image internal bitmap now) Image->Canvas->Pen->Color=c; Image->Canvas->Pen->Width=10; Image->Canvas->MoveTo(20, 0); Image->Canvas->LineTo(20, h); } Results: left - H<32768 (as expected), right H=32768 (usually random pieces of desktop).
  5. AlexBelo

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    > 32768 x 32768 x 24 bit ---> 3 Gb No, I mean any dimention (not both) like 1024*32768. I suspect that somewhere in VCL some "size parameter" is word (not cardinal). It would be nice to check this issue in current version.
  6. AlexBelo

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    After some experiments: - if I do StretchBlt manually into intermediate bmp the result is always correct (i.e. this API call works as expected even with huge bmp ~1Gb); - if I set Image->Stretched=true and perform Image->Picture->Assign(bmp), the resulting picture in Image on a form is totally wrong when bmp->Width or Height is >32767; tracing into Graphics unit doesn't show anything suspicious (the same call of StretchBlt with correct parameters) ... So as workaround I have to create stretched image manually...
  7. AlexBelo

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    > Graphics32 Unfortunately I can not use 32bit images due to memory limits. As I mentioned above I use RAD2007 and 32bit compiler. Even on Win64 (where 32bit app can use nearly 4 Gb of memory) I have not enough continuous memory for 32bit image (24bit bmp is still workable in my case).
  8. AlexBelo

    Stratched image is wrong if bmp dimention >32767 (RAD2007)

    Thank you for your response. Yes, I can create stretched bmp manually but for now I'd like to use a simple solution (if possible). > huge (more than a CD for a single image) Wow. Of course, you have no chance to process such picture with any thinkable API/hardware. My images are much smaller (like 2k*150k) but even them cause "Out of resourses". 🙂
  9. Hi all. I have a problem when I try to show a bmp in TImage when Image->Stratched=true. All work as expected when any bmp dimension is less than 32767. But higher dimensions lead to garbage in Image. Is this known limitation of WinAPI (can not find any in docs and Google) or bug in Graphics unit of RAD2007? TIA. -- Alex
  10. Hi all. Just for your information: IDE cannot find declaration with 32-bit clang compiler https://quality.embarcadero.com/browse/RSP-29732
  11. Hmm... Good option. 🙂 As documentation states: MapViewOfFile function (memoryapi.h) Maps a view of a file mapping into the address space of a calling process. So mapped view is in "my" address space. AFAIUI, OS gives me (and others who use the same mapped file) access to some "external" pages in memory but I see these pages as array allocated in "my" memory. And big view will take big continuous piece of virtual memory in my process. About TFileStream. As documentation states: ... file views derived from any file mapping object that is backed by the same file are coherent or identical at a specific time. Coherency is guaranteed for views within a process and for views that are mapped by different processes. (Not surprising: data resides in the same pages in memory.) AFAIUI "normal" files don't have such property.
  12. You are right in general when you say about direct manipulations with data in created view. But my main motivation here is standartization of data access with descendant of TStream.
  13. I still use RAD2007, it is 32bit. And yes - it is not hard to implement "walking" view. (But we always have a hope that someone already did it before. 🙂) Mapping view of big size (entire file as subcase) takes a lot of memory (no miracle here) so it is not "for free" even in 64bit OS.
  14. I don't want to expand file but operate with big file via mapped view of reasonable size; mapping view of entire file is impossible. Take a look: MapViewOfFile function https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile Mapping a file makes the specified portion of a file visible in the address space of the calling process. For files that are larger than the address space, you can only map a small portion of the file data at one time. When the first view is complete, you can unmap it and map a new view.
  15. Thank you for your responce. AFAICS both sources do not automatically process boundaries of currently mapped view during r/w operations . . . I.e. if start of r/w data block is in current view but its end is not then operation will fail. But I wish to r/w stream without thinking about boundaries of current view; Read/Write methods should move view (of predefined size) automatically. Of course, I can modify Read/Write methods myself to achieve necessary functionality.
×