Results 1 to 17 of 17

Thread: Bmp or any format

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I need either the source of a method like Loadpicture or a method that loads pictures from a position in a file with a specified length.

    Any ideas?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    WOW I didn't think that a Guru would ever be asking a question.

    but this might work:

    Code:
    Private Sub Command1_Click()
    Image1.Picture = ".../******.bmp" 'every * stands for a character
    End Sub
    NXSupport - Your one-stop source for computer help

  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    I think that is the great thing about Kedaman. Status is unimportant to him.

    Ked! Maybe you can search for it in the Microsoft site. Not sure!
    Chemically Formulated As:
    Dr. Nitro

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    You're doing this for your PAK-Type Project, Aren't you? Well, I think you've already done it, because you sent me the dll. If not, here goes:

    NOTES:
    Pos = StartPos of this file
    NPos = StartPos of the file after this one
    MyFile = The File you will be getting the data from
    Code:
    Dim f
    dim OCx as long
    dim Cx as long
    dim Length as Long
    dim Chunk as long
    dim OChunk as long 
    dim TEMP
    dim MyPicToSave
    dim Start as byte
    
    length = npos - pos
    
    do
      cx=cx+1
      chunk = space$(pos / cx)
      if pos / cx = int(pos / cx) then
        exit loop
      end if
    loop
    
    start = pos
    
    do
      ocx=ocx+1
      ochunk = space$(length / ocx)
      if length / ocx = int(length / ocx) then
         exit loop
      end if
    loop
    
    f=freefile
    
    open myfile for binary as f
      for a = 1 to cx
         get f,,chunk
      next a
      for a = 1 to ocx
         get f,,ochunk
         mypictosave=mypictosave & ochunk
      next a
      mypictosave = trim$(mypictosave)
    close f
    
    open app.path & "\temp.bmp" for binary as f
      put f,,mypictosave
    close f
    
    picture1.picture = loadpicture(app.path & "\temp.bmp")
    Instead of:

    Open MyFile For Binary as F
    For A = 1 to CX
    Get f,,chunk
    Next A

    You could do this:

    Open MyFile For Binary as F
    Get F,Start,Temp

    I'm not sure that this will work, but I'm pretty confident.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Nah, i could as well you the fileextract function and loadpicture. BTW, that's 64 bit and slow.

    Just need a method like Loadpicture that loads the file from within a file, in this case my package.

    Or i would need the source for such kind of function so that i can modify it.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    But does it work? (Even though it's 64 bit + slow?)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Not sure, haven't tested, but what i need is something that reads once, not read, write and read again.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Lively Member
    Join Date
    May 2000
    Posts
    84
    What do you mean by load a picture from within a file? Do you mean that the whole bitmap file is just a part of a larger file? If so then this could be done if you could extract the bitmap portion, header and all, into a byte array.

    You would use the first 1078 bits to fill an info structure containing the image header and color table. The last part of the file would then be passed to another array to contain only the image bits.

    With these structures you can then use CreateDiBitmap to create the bitmap in a memory DC.

    If you need code I will supply it.

  9. #9

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hehe, i knew somone would find something usefull,
    thanks Illuminator, i'll need the code
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    New Member
    Join Date
    Jun 2000
    Posts
    11
    Yes, creating a bitmap in memory from a BMP byte array sounds very feasible, although I've never done it. But reading JPGs or GIFs from memory would probably require you to first save the pic(s) temporarily and then use the LoadPicture function.

    Illuminator, I would also like to see the code. This idea could be used in many of my and others' projects.

    Thanks

    (Just wondering, is it possible to store an OLE object in a text file and then read it back?)
    Alex Begey
    CrystalDev
    VB6 SP4

  11. #11
    Lively Member
    Join Date
    May 2000
    Posts
    84
    I will assume you are familliar with creating a memory DC and proficient at finding the API function definitions.

    Code:
    'API Functions
    CreateCompatibleDC
    DeleteDC
    SelectObject
    DeleteObject
    CreateDIBitmap 
    BitBlt ' or simialr function
    
    'Bitmap Structure Types
    Public Type BITMAPFILEHEADER
            bfType As Integer
            bfSize As Long
            bfReserved1 As Integer
            bfReserved2 As Integer
            bfOffBits As Long
    End Type
    
    Public Type BITMAPINFOHEADER '40 bytes
            biSize As Long
            biWidth As Long
            biHeight As Long
            biPlanes As Integer
            biBitCount As Integer
            biCompression As Long
            biSizeImage As Long
            biXPelsPerMeter As Long
            biYPelsPerMeter As Long
            biClrUsed As Long
            biClrImportant As Long
    End Type
    
    Public Type RGBQUAD
            rgbBlue As Byte
            rgbGreen As Byte
            rgbRed As Byte
            rgbReserved As Byte
    End Type
    
    Public Type BITMAPINFO
            bmiHeader As BITMAPINFOHEADER
            bmiColors(256) As RGBQUAD
    End Type
    
    'Varibles
    Public FileHeader As BITMAPFILEHEADER
    Public Info As BITMAPINFO  
    Public FilePath as string
    Public Image_Array() as byte  'An array that will contain only the image bits
    Public hDC as Long 'the handle to the memory DC'
    
    
    Sub Create_Bitmap()
    
    Dim Temp As String
    Temp = FreeFile
    
    Dim Image_Start as Long
    Image_Start = ????  '<- set the start position of the image within the file
    
    Open FilePath For Binary Access Read As #Temp
        Get #Temp, Image_Start, FileHeader
        Get #Temp, , Info.bmiHeader
        Get #Temp, , Info.bmiColors
        Redim Image_array(Info.bmiHeader.biWidth-1, Info.bmiHeader.biHeight-1) as byte
        Get #Temp, , Image_Array()
    Close Temp
    
    SelectObject hDC, CreateDIBitmap(hDC, Info.bmiHeader, &H4, Image_Array(0, 0), Info, 2)
    
    'from here on you can use the Hdc to reference the image and use bitblt and other functions.
    
    End Sub

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Slightly off-topic, but for things like this where there are lots of complex API declarations, try using Bruce McKinney's Win32 API Type Library. I've had it for a while and it makes development so much quicker.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well, i'm just interested in loading directly from withing a file, I guess i can't get directly onto a directdrawsurface but getting to a DC is enough, I can use createsurfacefromDC.

    Many thanks to you Illuminator.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  14. #14
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Hey Kedaman, are you going to include that in the next version of KedaPack? Or should I make it a part of my DLL? I hope you don't mind, Illuminator, but I need to use that code as well. !
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  15. #15

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'll include, i'll try to include as much as possible in the DLL.

    So you call it like:
    Kedapack1.LoadBitmap path, Picture1.hDC
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  16. #16
    Hyperactive Member Eyes.Only's Avatar
    Join Date
    Oct 2001
    Location
    Minnesota
    Posts
    347
    i need to do the same thing but with jpg and gif as well as the bmp... Anyone come across something since this thread was started?

  17. #17
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    If you don't want to dive into those formats yourself, you should do the temporary file way (as illustrated above).
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width