Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CFile::ReadHuge question

CFile::ReadHuge question

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformance
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BlackRider
    wrote on last edited by
    #1

    Hello everybody, I'm reading a .jpg file, everything goes fine, readhuge reports reading the hole file but what I've got in the buffer is just 4 bytes. What is ReadHuge reading ? code: buffer = new char[1000000]; if (buffer == NULL) { cout<<"Not enough memory"; return; } try { imageFile.Open(fileTitle,CFile::modeRead,&e); imageFile.ReadHuge(buffer,1000000); imageFile.Close(); CString output = header + buffer; imageFile.Open("msg01",CFile::modeCreate | CFile::modeWrite,&e); imageFile.WriteHuge((LPCTSTR) output,output.GetLength()); imageFile.Close(); delete []buffer; }

    S 1 Reply Last reply
    0
    • B BlackRider

      Hello everybody, I'm reading a .jpg file, everything goes fine, readhuge reports reading the hole file but what I've got in the buffer is just 4 bytes. What is ReadHuge reading ? code: buffer = new char[1000000]; if (buffer == NULL) { cout<<"Not enough memory"; return; } try { imageFile.Open(fileTitle,CFile::modeRead,&e); imageFile.ReadHuge(buffer,1000000); imageFile.Close(); CString output = header + buffer; imageFile.Open("msg01",CFile::modeCreate | CFile::modeWrite,&e); imageFile.WriteHuge((LPCTSTR) output,output.GetLength()); imageFile.Close(); delete []buffer; }

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      The jpg contains binary NUL characters; your output = header + buffer statement will append the buffer up to the first NUL byte (or WORD, if you're using UNICODE), so GetLength() isn't giving you a big enough number. Steve S

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups