Home All Groups Group Topic Archive Search About
Post Other interesting topics
Author
13 May 2009 11:57 AM
JIm
I have been asked to update a website.  There are about 100 web pages
whose urls I know but it will take a while for me to get ftp access
(corporate stuff).  Is there a way for me to automate the process in
vb 6 of downloading all the pages as well as the images.  It would
save me a lot of time

Author
13 May 2009 9:24 PM
Ivar
Hi all.

Lets assume I have a BitMap image and there are 8 bits per pixel, I have my
BITMAPINFOHEADER and 1024 bytes of colour info for a 32 X 32 image.
Is there a way of getting the 24 bit colour that will be displayed if using
the SetDIBitsToDevice Api. I can do it by creating DCs and bitmaps and
applying the bits then checking the colour of the Pixel (GetPixel Api), but
is there a way of doing this without using the APIs to create pictures and
DCs first.

Thanks for any pointers for this

Ivar
Author
13 May 2009 10:00 PM
Jim Mack
Ivar wrote:
> Hi all.
>
> Lets assume I have a BitMap image and there are 8 bits per pixel, I
> have my BITMAPINFOHEADER and 1024 bytes of colour info for a 32 X
> 32 image. Is there a way of getting the 24 bit colour that will be
> displayed if using the SetDIBitsToDevice Api. I can do it by
> creating DCs and bitmaps and applying the bits then checking the
> colour of the Pixel (GetPixel Api), but is there a way of doing
> this without using the APIs to create pictures and DCs first.
>
> Thanks for any pointers for this

The 1024 bytes would be a table that the 8-bit pixel value indexes.
That probably makes the entries 16 bits each, or 5-6-5 color. The
system should use those as the high-order bits of an 8-8-8 (24 bit
RGB) color.

Just speculation though. I'm sure an expert will be along any second.
(-:

--
        Jim
Author
13 May 2009 12:34 PM
Ralph
<J**@aol.com> wrote in message
news:g8dl055o6q5qka4oe2gfrrsrl6roue82nj@4ax.com...
> I have been asked to update a website.  There are about 100 web pages
> whose urls I know but it will take a while for me to get ftp access
> (corporate stuff).  Is there a way for me to automate the process in
> vb 6 of downloading all the pages as well as the images.  It would
> save me a lot of time
>

I'm probably missing something, but until you get your hands on the physical
files all you are going to get is "rendered" pages and "rendered" images no
matter what tool you use to view or capture them. These files might be
useful if there is no server-side scripting going on, but that is hard to
believe in this day and age.

Once you get physical access to the files there are numerous utilities
available to managing "Web Projects". I'd spend my time researching these
tools.

-ralph
Author
13 May 2009 10:12 PM
Schmidt
"Jim Mack" <jmack@mdxi.nospam.com> schrieb im Newsbeitrag
news:uGyUrYB1JHA.1248@TK2MSFTNGP06.phx.gbl...

> The 1024 bytes would be a table that the 8-bit pixel value indexes.
> That probably makes the entries 16 bits each, or 5-6-5 color. The
> system should use those as the high-order bits of an 8-8-8 (24 bit
> RGB) color.

8Bit per Pixel gives 256 different ColorIndexes (duh...<g>),
which then point into the 256 * 4Bytes (32Bit per Color)
Lookup-Table.
This 1024 Byte large Lookup-Table is organized in a
"plain way" - one Color after the other, so no Channel-
splitting here:

BGRA|BGRA|BGRA|...etc.
and the above BGRA-sequence 256 times.

One can read that into a VB-Array with that structure:
Type BGRA
    B as Byte
    G as Byte
    R as Byte
    A as Byte
End Type

Dim LUT256(0 to 255) As BGRA

then Move-Memory from the End of the DIB into
LUT256(0) and the Colors are available in the App.

Olaf
Author
14 May 2009 2:36 AM
Nobody
"Ivar" <Ivar.ekstromer***@ntlworld.com> wrote in message
news:KUGOl.48146$i%2.42943@newsfe15.ams2...
> Hi all.
>
> Lets assume I have a BitMap image and there are 8 bits per pixel, I have
> my BITMAPINFOHEADER and 1024 bytes of colour info for a 32 X 32 image.
> Is there a way of getting the 24 bit colour that will be displayed if
> using the SetDIBitsToDevice Api. I can do it by creating DCs and bitmaps
> and applying the bits then checking the colour of the Pixel (GetPixel
> Api), but is there a way of doing this without using the APIs to create
> pictures and DCs first.

Search MSDN Library for "Bitmap Header Types" using the Search tab and by
titles only.
Author
14 May 2009 3:08 AM
Nobody
"Nobody" <nob***@nobody.com> wrote in message
news:OcLpgzD1JHA.6132@TK2MSFTNGP04.phx.gbl...
> Search MSDN Library for "Bitmap Header Types" using the Search tab and by
> titles only.

The above doesn't give the file format. For file format, search for "Bitmap
Storage".
Author
14 May 2009 3:18 AM
Nobody
See this sample, which reads BMP files and manipulate them directly:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3500&lngWId=1
Author
14 May 2009 7:11 AM
Ivar
Thanks for the replies so far.
To demo my problem I've put a bit of code below, add a command button on a
form and paste the code.

The question is:
How to know what long colour will windows draw for each bye value

Thanks

Ivar

The Code:

Option Explicit
Private Declare Function SetDIBitsToDevice Lib "gdi32" _
(ByVal hdc As Long, ByVal X As Long, _
ByVal y As Long, ByVal dx As Long, ByVal dy As Long, _
ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, _
ByVal NumScans As Long, Bits As Any, BitsInfo As Any, _
ByVal wUsage As Long) As Long

Private Declare Function GetPixel Lib "gdi32" _
(ByVal hdc As Long, ByVal X As Long, ByVal y As Long) As Long

Private Type BITMAPINFOHEADER
   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

Private Sub Command1_Click()
Dim TheHeader As BITMAPINFOHEADER
Dim I As Integer
Dim TheBytes(1023) As Byte
'Create a BitMap header
With TheHeader
..biClrUsed = 256
..biBitCount = 8
..biHeight = 32
..biWidth = 32
..biPlanes = 1
..biSize = 40
End With
'Asign random values for random colours
For I = 1 To 1023
TheBytes(I) = Int(225 * Rnd)
Next
'How to know what colour (Long) will be drawn without
'the following code
Me.ScaleMode = vbPixels
Me.AutoRedraw = True
SetDIBitsToDevice Me.hdc, 0, 0, _
32, 32, 0, 0, 0, 32, TheBytes(0), TheHeader, 0&
Me.Refresh
'Find long value of colour at top right corner
'The last pixel to be drawn, Byte index 1023
Me.Caption = TheBytes(1023) & " = " & GetPixel(Me.hdc, 0, 31)
End Sub
Author
14 May 2009 2:17 PM
Schmidt
"Ivar" <Ivar.ekstromer***@ntlworld.com> schrieb im Newsbeitrag
news:cuPOl.106124$IC1.30086@newsfe06.ams2...

> The question is:
> How to know what long colour will windows draw for
> each bye value

Adjusted your Code somewhat and made some comments
inside.

'***Into a Form, then click the Form
Option Explicit

Private Declare Function SetDIBitsToDevice Lib "gdi32" _
  (ByVal hdc As Long, ByVal x As Long, _
  ByVal y As Long, ByVal dx As Long, ByVal dy As Long, _
  ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, _
  ByVal NumScans As Long, Bits As Any, BitsInfo As Any, _
  ByVal wUsage As Long) As Long

Private Declare Function GetPixel Lib "gdi32" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

Private Type BGRA
  B As Byte
  G As Byte
  R As Byte
  A As Byte
End Type

Private Type BITMAPINFOHEADER_WithPalette
   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
   Palette(0 To 255) As BGRA
End Type

Private Sub Form_Click()
Dim i As Long, TheHeader As BITMAPINFOHEADER_WithPalette
Dim PxlArr(0 To 31, 0 To 31) As Byte 'these are your Pixels(only Indexes)

  'Create a BitMap header
  With TheHeader
    .biClrUsed = 256
    .biBitCount = 8
    .biHeight = -32 'DIBs are "bottom-up", a neg. height ensures a flip
    .biWidth = 32
    .biPlanes = 1
    .biSize = 40

    'Define some Colors, ranging only from black to "pure blue"
    For i = 0 To 255
      With .Palette(i)
        .B = i
      End With
    Next i
  End With

  'since the above was only a Color-Definition, we now have
  'to define, which of the 256 different "darkened blue"
  'indices we want to choose in our small 32x32 Bitmap
  Dim x As Long, y As Long
  For y = 0 To UBound(PxlArr, 2)
    For x = 0 To UBound(PxlArr, 1)
      'let's try something like a "diagonal gradient"...
      'but keep in mind, these are only indices, not the colors...
      'though - the higher the index, the more blueish it gets
      PxlArr(x, y) = (x + 1) * (y + 1) / (32 * 32) * 255
    Next x
  Next y

  'now draw what we have
  If Not AutoRedraw Then AutoRedraw = True
  SetDIBitsToDevice hdc, 0, 0, 32, 32, 0, 0, 0, 32, _
                    PxlArr(0, 0), TheHeader, 0&
  Refresh

  'How to know what colour (Long) will be drawn...?
  Dim ColorBottomRightPxl As Long
  With TheHeader.Palette(PxlArr(31, 31)) 'PxlArr points into the palette
    ColorBottomRightPxl = RGB(.R, .G, .B)
  End With

  'small test:
  Caption = Hex(ColorBottomRightPxl) & " " & Hex(GetPixel(hdc, 31, 31))
End Sub

Olaf
Author
13 May 2009 12:59 PM
Jim
You are correct.  All we really want is the content so we can get a
jumpstart on updating the text and images.  Layout etc dose not matter
right now

On Wed, 13 May 2009 07:34:23 -0500, "Ralph"
<nt_consultin***@yahoo.com> wrote:

Show quoteHide quote
>
><J**@aol.com> wrote in message
>news:g8dl055o6q5qka4oe2gfrrsrl6roue82nj@4ax.com...
>> I have been asked to update a website.  There are about 100 web pages
>> whose urls I know but it will take a while for me to get ftp access
>> (corporate stuff).  Is there a way for me to automate the process in
>> vb 6 of downloading all the pages as well as the images.  It would
>> save me a lot of time
>>
>
>I'm probably missing something, but until you get your hands on the physical
>files all you are going to get is "rendered" pages and "rendered" images no
>matter what tool you use to view or capture them. These files might be
>useful if there is no server-side scripting going on, but that is hard to
>believe in this day and age.
>
>Once you get physical access to the files there are numerous utilities
>available to managing "Web Projects". I'd spend my time researching these
>tools.
>
>-ralph
>
Author
13 May 2009 1:35 PM
mayayana
> You are correct.  All we really want is the content so we can get a
> jumpstart on updating the text and images.  Layout etc dose not matter
> right now
>

  First....if the company doesn't have at least
one copy of the site backed up offline then
there's something very wrong.

But that aside....

  Why not just load a page in a browser and
save it with all associated files? If you need
to work on editing text and updating images
then you probably don't need many pages to
get started. And downloading it that way
would allow you to keep the CSS and image
files in a neat package with the page. As Ralph
said, you can't really download the site files anyway.

  If you really need to download more you can
use a "download helper" like HTTrack, as Nobody
said. There's not much point in writing something
like that. But there are caveats, as Ralph pointed
out. A lot of sites compile a page server-side.
If you're just downloading pages then you may
not be getting anything even close to the actual
website files. Also, some sites may block things
like HTTrack. (On my own site I try to block all
"helpers" and "scrapers", and I serve different pages
to IE and non-IE. Those are two examples of
problems you might run into.)

    I once tried HTTrack and found that it seemed
to fail more often than not. Maybe that's because a
lot of sites block it, or maybe it's related to the lack
of actual webpage files on sites that are building pages
from a database as they're requested. I'm not sure.
Author
13 May 2009 10:03 PM
Jim
Answer to offsite etc questions is that I signed to contract but it
takes a few weeks to get users rights etc and I want to jump start the
project

HTTtrackr did not work because I could not get the cookies to read
properly despite moving the cookie to every known place

I downloaded a vb program that I modified to save the web pages but I
can not rewrite
this line of cade

ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER,

to
1- Not prompt user for a file name
2-HAve the default save as Web page and Graphics (seperatley0

Any help s appreciated

Show quoteHide quote
On Wed, 13 May 2009 09:35:21 -0400, "mayayana" <mayaXXy***@rcXXn.com>
wrote:

>> You are correct.  All we really want is the content so we can get a
>> jumpstart on updating the text and images.  Layout etc dose not matter
>> right now
>>
>
>  First....if the company doesn't have at least
>one copy of the site backed up offline then
>there's something very wrong.
>
>But that aside....
>
>  Why not just load a page in a browser and
>save it with all associated files? If you need
>to work on editing text and updating images
>then you probably don't need many pages to
>get started. And downloading it that way
>would allow you to keep the CSS and image
>files in a neat package with the page. As Ralph
>said, you can't really download the site files anyway.
>
>  If you really need to download more you can
>use a "download helper" like HTTrack, as Nobody
>said. There's not much point in writing something
>like that. But there are caveats, as Ralph pointed
>out. A lot of sites compile a page server-side.
>If you're just downloading pages then you may
>not be getting anything even close to the actual
>website files. Also, some sites may block things
>like HTTrack. (On my own site I try to block all
>"helpers" and "scrapers", and I serve different pages
>to IE and non-IE. Those are two examples of
>problems you might run into.)
>
>    I once tried HTTrack and found that it seemed
>to fail more often than not. Maybe that's because a
>lot of sites block it, or maybe it's related to the lack
>of actual webpage files on sites that are building pages
>from a database as they're requested. I'm not sure.
>
Author
13 May 2009 11:12 PM
mayayana
It looks like this is what you want, but it's
not as flexible as you'd like. ExecWB is just
simple IE automation:

http://msdn.microsoft.com/en-us/library/ms683930(VS.85).aspx

Show quoteHide quote
> I downloaded a vb program that I modified to save the web pages but I
> can not rewrite
> this line of cade
>
> ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER,
>
> to
> 1- Not prompt user for a file name
> 2-HAve the default save as Web page and Graphics (seperatley0
>
> Any help s appreciated
Author
14 May 2009 2:56 AM
JIm
tried

OLECMDEXECOPT_DONTPROMPTUSER

But cannot find where it was saved to



Show quoteHide quote
On Wed, 13 May 2009 19:12:54 -0400, "mayayana" <mayaXXy***@rcXXn.com>
wrote:

>It looks like this is what you want, but it's
>not as flexible as you'd like. ExecWB is just
>simple IE automation:
>
>http://msdn.microsoft.com/en-us/library/ms683930(VS.85).aspx
>
>> I downloaded a vb program that I modified to save the web pages but I
>> can not rewrite
>> this line of cade
>>
>> ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER,
>>
>> to
>> 1- Not prompt user for a file name
>> 2-HAve the default save as Web page and Graphics (seperatley0
>>
>> Any help s appreciated
>
>
Author
14 May 2009 3:40 AM
mayayana
>
> OLECMDEXECOPT_DONTPROMPTUSER
>
> But cannot find where it was saved to


  You could try monitoring it with Filemon, but
it should just be whatever IE defaults to. That
method is supposed to be the same as clicking
File -> SaveAs in IE, so whatever that FileSave
dialogue suggests as the path for saving should
be where the file ends up.

  There are other less clunky ways to download a
file, but if you want IE to do it you could also
try using a WB control to navigate to the page,
then save the content. If I remember correctly,
document.body.outerHTML is the most inclusive
property. Doing it that way would also provide the
option to parse the HTML for CSS files and IMG tags.