Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From an array of HEX Codes to a collection of JPG files?

Status
Not open for further replies.

fulltime68

Technical User
May 11, 2006
4
SG
Hi all,

I am a array of hex codes, a portion of which is shown below.

Code:
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x04, 0x00, 0x04, 0x7F, 0xE0, 
	0x40, 0x04, 0x00, 0x48, 0x3F, 0xC0, 0x40, 0x04, 0x00, 0x40, 0x04, 0x00, 0x42, 0xFF, 0xF0, 0x00, 
	0x00, 0x01, 0x10, 0xFF, 0xE1, 0x10, 0x07, 0x87, 0x80, 0x48, 0xC2, 0x50, 0x12, 0x4F, 0xFE, 0x04, 
	0x03, 0x58, 0x44, 0x48, 0xC2, 0x04, 0x00, 0x00, 0x00, 0x01, 0x18, 0x0A, 0x07, 0xFC, 0x44, 0x44, 
	0x44, 0x7F, 0xC4, 0x44, 0x44, 0x47, 0xFC, 0x04, 0x0F, 0xFF, 0x04, 0x00, 0x40, 0x04, 0x00, 0x00, 
	0x00, 0x00, 0x04, 0x7F, 0xE0, 0x08, 0x3F, 0xCA, 0x4A, 0xA4, 0xAB, 0xFA, 0xA4, 0xAA, 0x4A, 0xBF,

each "0x00" represents one byte and every 24 bytes represent a character which is a 12*16 image. My question is how can i take this array n generate its equivalent character into seperate JPG files? i.e take 1st 24bytes, convert, then save as a jpeg file, then take the 2nd 24bytes, convert n save as 2nd jpeg file and etc..

i need to achieve the above using VBA..Can anyone help me pls?

Thks
FT :)
 


Hi,

What do you have so far? Please post your code.

Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
wat i have in Visual basic is as shown below.. however, i wan to know how i can get it done in VBA... if i am correct, VBA doesnt recognise hDC, does tat mean i cant use SetPixelV?? so how can i create a control to use hdc? thks

Code:
Option Explicit
Private Declare Function SetPixelV Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long

Private Sub Command1_Click()
Dim I As Long, Bit As Long, A() As String, B() As Byte

'build an array just for demo purposes
A = Split("00 00 C0 04 00 04 7F E0 40 04 00 48 3F C0 40 04 00 40 04 00 42 FF F0 00", " ")
ReDim B(UBound(A))
For I = 0 To UBound(B)
  B(I) = Val("&h" & A(I))
Next

'draw that character!
For I = 0 To UBound(B)
  For Bit = 0 To 7
    If B(I) And 2 ^ Bit Then
      SetPixelV Me.hDC, (7 - Bit + I * 8) Mod 12, (7 - Bit + I * 8) \ 12, &H0
    End If
  Next
Next
End Sub
 

you have hDC defined as LONG. Loose the Me. reference.
Code:
          SetPixelV [b][s]Me.[/s]hDC[/b], (7 - Bit + I * 8) Mod 12, (7 - Bit + I * 8) \ 12, &H0

Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
hi,

when i execute the above codes in MS access, why does it give me a "variable not defined" error referring to the hDC variable?? i tot its already declared on top?
 


You gave no indication of the nature of your form. me.hdc is a form OBJECT. hDB is defined as LONG in the funciton you are calling. There's a missmatch there. where is ms.hdc coming from?

Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
hi,

i agree w wat u said, there is a type mismatch, but to use setpixel, i need to provide the hdc where the pixels are to be set. So in this case, i wan to draw it on the form, and since i cannot use Me.hDC, wat do u suggest i do?

regards,
FT :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top