|
-
Aug 10th, 2000, 04:49 PM
#1
Thread Starter
transcendental analytic
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.
-
Aug 10th, 2000, 05:41 PM
#2
Frenzied Member
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
-
Aug 10th, 2000, 07:02 PM
#3
Fanatic Member
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
-
Aug 10th, 2000, 07:29 PM
#4
Good Ol' Platypus
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)
-
Aug 11th, 2000, 07:19 AM
#5
Thread Starter
transcendental analytic
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.
-
Aug 11th, 2000, 10:29 AM
#6
Good Ol' Platypus
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)
-
Aug 11th, 2000, 01:48 PM
#7
Thread Starter
transcendental analytic
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.
-
Aug 11th, 2000, 02:06 PM
#8
Lively Member
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.
-
Aug 11th, 2000, 02:10 PM
#9
Thread Starter
transcendental analytic
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.
-
Aug 11th, 2000, 02:27 PM
#10
New Member
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
-
Aug 11th, 2000, 03:59 PM
#11
Lively Member
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
-
Aug 11th, 2000, 06:03 PM
#12
Monday Morning Lunatic
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
-
Aug 11th, 2000, 06:51 PM
#13
Thread Starter
transcendental analytic
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.
-
Aug 11th, 2000, 09:47 PM
#14
Good Ol' Platypus
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)
-
Aug 12th, 2000, 06:27 AM
#15
Thread Starter
transcendental analytic
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.
-
Oct 26th, 2002, 11:58 PM
#16
Hyperactive Member
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?
-
Oct 27th, 2002, 12:47 AM
#17
Good Ol' Platypus
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|