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#
  4. How to get Image from other Image quickly

How to get Image from other Image quickly

Scheduled Pinned Locked Moved C#
graphicswinformsalgorithmsperformancehelp
4 Posts 3 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.
  • L Offline
    L Offline
    Libor Tinka
    wrote on last edited by
    #1

    I need to divide a very large image (say 5-7 mpx) into smaller pieces (24 bpp Image objects). Algorithm is not a problem, the speed of used GDI+ method is. Using Graphics.DrawImage() is slow, even when no interpolation is done. The problem is not in the count of pieces, but in the size of huge source image. Doesn't matter how large the pieces are, because the long time is taken by the reading of pixels from source. I've thought about using unsafe pixel access, but still hope there's some method for obtaining smaller image from larger one quickly.

    J R 2 Replies Last reply
    0
    • L Libor Tinka

      I need to divide a very large image (say 5-7 mpx) into smaller pieces (24 bpp Image objects). Algorithm is not a problem, the speed of used GDI+ method is. Using Graphics.DrawImage() is slow, even when no interpolation is done. The problem is not in the count of pieces, but in the size of huge source image. Doesn't matter how large the pieces are, because the long time is taken by the reading of pixels from source. I've thought about using unsafe pixel access, but still hope there's some method for obtaining smaller image from larger one quickly.

      J Offline
      J Offline
      Jun Du
      wrote on last edited by
      #2

      Libor Tinka wrote:

      because the long time is taken by the reading of pixels from source

      I wouldn't read pixels. Locate each small piece on the original image and draw it to a separate graphic buffer. Then, you may either save it to a file or render it to the screen.

      Best, Jun

      L 1 Reply Last reply
      0
      • J Jun Du

        Libor Tinka wrote:

        because the long time is taken by the reading of pixels from source

        I wouldn't read pixels. Locate each small piece on the original image and draw it to a separate graphic buffer. Then, you may either save it to a file or render it to the screen.

        Best, Jun

        L Offline
        L Offline
        Libor Tinka
        wrote on last edited by
        #3

        The drawing to separate buffer (doesn't matter how small the buffer is) is slow when working with large images. Drawing small area of 10 by 10 pixels from position [x,y] using graphics.DrawImage(srcImage, new Rectangle(0, 0, 10, 10), x, y, 10, 10) looks fast - try it on 7 megapixel image, it won't be.

        1 Reply Last reply
        0
        • L Libor Tinka

          I need to divide a very large image (say 5-7 mpx) into smaller pieces (24 bpp Image objects). Algorithm is not a problem, the speed of used GDI+ method is. Using Graphics.DrawImage() is slow, even when no interpolation is done. The problem is not in the count of pieces, but in the size of huge source image. Doesn't matter how large the pieces are, because the long time is taken by the reading of pixels from source. I've thought about using unsafe pixel access, but still hope there's some method for obtaining smaller image from larger one quickly.

          R Offline
          R Offline
          Ranjan Banerji
          wrote on last edited by
          #4

          If you want speed then dont use GDI. Use unsafe code. here is an example of using unsae code to handle bitmaps. Does not do what you want, but I am sure you can figure it out :-) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp11152001.asp[^]

          My pointless rants meragussa.blogspot.com[^]

          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