Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Font Class and SHLoadImage (WM2005 updates)


Font Class and SHLoadImage (WM2005 updates)

Postby Guest » Aug 9, 2006 @ 9:16am

Hi Everyone,

I recently followed Presto's instructions to modify image.cpp to remove dependency on imgdecmp.dll by using SHLoadImage instead.

This works great on WM2005 devices as well as older (2002/2003) devices. However, I'm finding that the font class (written by Thomas 'gersen' Maniero) no longer works with this change. The bitmap fonts display correctly on WM2005 devices, but if I load my game on early 2003 devices, the bitmap fonts won't display at all.

From what I can tell, the m_rect surface size that is used in the Font::draw method is not being generated correctly.
Code: Select all

   display->Blit(x, y, m_surf, &m_rect[str[i]]);
1 lines; 0 keywds; 0 nums; 13 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  

I can pass in a &Rect with a fixed size and get part of the font bitmap to display which tells me this may be part of the problem. However, I don't have the expertise to understand the font class well enough to come up with a real solution.

Does anyone else use the font class with the WM2005 updates (SHLoadImage) for PocketFrog? If so, did you have to make any changes to the font class to get your bitmap fonts to display on both WM2005 and 2002/2003 devices?

Thanks!
:D
Guest
 


Postby Presto » Aug 9, 2006 @ 3:21pm

I still use gersen's font class, though it's heavily modified now. For my games, they work fine on 2002 and higher devices. I can't think of any specific changes I made to get it to work, though I did add an extra "load" function to the font class for loading fonts from files. But I'm also loading fonts from resources, so it shouldn't matter.
Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
bool MyFont::load(DisplayDevice* display, TCHAR *sFontPath)
{
  uint32_t h, w, i, pos;

  for(= 0; i <= 255; i++)
    m_rect[i].Set(0, 0, 0, 0);

  // carico superficie contenente il font
  m_surf = LoadImage(display, sFontPath);
  if(m_surf == 0)
    return false;

  m_surf->SetColorMask(Color(255,0,255));

  h = m_surf->GetHeight();

  // trovo primo mark, i pixel per lo spazio
  pos = 0;
  w = findNextMark(&pos, m_surf);
  if(!= 0)
    m_space = w;
  else
    return false;

  i = 0;
  while(trs[i] != 0)
  {
    // MSR: check for end of table
    // se non trovo un mark allora ho controllato tutta l'immagine, esco
    w = findNextMark(&pos, m_surf);
    if(== 0)
      break;

    // setto rettangolo. se ho settato 255 rect allora ho finito
    m_rect[trs[i]].Set(pos-w, 1, pos, h);
    i++;
    if(> 255)
      break;
  }

  return true;
}
42 lines; 16 keywds; 17 nums; 112 ops; 0 strs; 5 coms    Syntactic Coloring v0.4 - Dan East  
Note that this code is from a PF 0.7 project, so if you're using 0.8 with PHAL, you'll have a "Display" type instead of "DisplayDevice" type.
User avatar
Presto
pm Insider
 
Posts: 763
Joined: Jan 20, 2003 @ 5:51am
Location: Kalesian Archipelago


Postby Bapdude » Aug 9, 2006 @ 6:02pm

Hi Presto,

(BTW, I wrote the original post...I forgot to login). :oops:

Thanks for the reply. I've spent hours trying to find what is causing the problem in my font class. Is there any chance you could send me a copy of your entire 'font.cpp' file? I know that's a lot to ask, but I can't think of any other way to quickly determine the difference.

I would greatly appreciate it!

Thanks...
:D
User avatar
Bapdude
pm Member
 
Posts: 140
Joined: May 14, 2004 @ 5:06am


Postby Presto » Aug 9, 2006 @ 6:58pm

Here you go...

I stripped out my extra functions, which don't have any impact on the actual "draw" functions, so a simple case like the following should work:
Code: Select all




MyFont fMyFont;
DisplayDevice *pDisplay = GetDisplay();
fMyFont.load(pDisplay, _T("tahoma_8pt.gif"));
fMyFont.draw(pDisplay, 120, 155, FONT_CENTER, _T("Testing..."));
4 lines; 0 keywds; 2 nums; 23 ops; 2 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  
I tested it, and it seems to be working like it's supposed to.

Oh yeah... cTransparent = Color(255,0,255). You'll see it referenced in MyFont.cpp right after it loads the image.

-John
Attachments
MyFont.zip
Simple font class.
(3.26 KiB) Downloaded 356 times
User avatar
Presto
pm Insider
 
Posts: 763
Joined: Jan 20, 2003 @ 5:51am
Location: Kalesian Archipelago


Postby Guest » Aug 9, 2006 @ 7:26pm

Woohoo!!! It works!! I still can't imagine what I did that caused my font class to stop working on older devices (it worked fine on WM2005). But, with your help, everything is working now...the birds are singing and the sun is shining! :D

John, if I can ever offer any help to you, please don't hesitate to ask.

Many thanks!!!
-Bobby
Guest
 


Postby Bapdude » Aug 9, 2006 @ 7:31pm

Wouldn't you know it, I forgot to login again. 8O But, the last post was by me.

Thanks again!

-Bobby
User avatar
Bapdude
pm Member
 
Posts: 140
Joined: May 14, 2004 @ 5:06am


Postby Presto » Aug 9, 2006 @ 8:58pm

Glad I could help. :)

Now you can add some nifty new functions to the class to change the letter spacing, unload the fonts, etc. ;)

BapDude wrote:John, if I can ever offer any help to you, please don't hesitate to ask.
You don't happen to have a terrific artist I could borrow, eh? :roll:

Later,
-John
User avatar
Presto
pm Insider
 
Posts: 763
Joined: Jan 20, 2003 @ 5:51am
Location: Kalesian Archipelago


Postby Bapdude » Aug 9, 2006 @ 9:52pm

Yeah, I've already added some functions for spacing, etc. to the font class. Of course, I guess in the process, I messed something else up and caused the whole thing to stop working. :wink:

Unfortunately, I don't have a good graphic artist to recommend. I do all my graphics myself with photoshop. I've thought about hiring a graphic artist in the past, but I never could justify the cost. I figured I would just play around with Photoshop until I came up with something that looked nice. At least that's my approach. :D
User avatar
Bapdude
pm Member
 
Posts: 140
Joined: May 14, 2004 @ 5:06am


Postby Conan » Aug 16, 2006 @ 7:26am

remember: most graphic artists want paid. They tend to flame programmers who want something for nothing. I found a student who was happy to work for reasonable rates but that was 3D not 2D. I even found a chap who had worked on Disney stuff & he produced these super demos that I could not afford.
What is Best in Life ?
User avatar
Conan
pm Member
 
Posts: 1309
Joined: Dec 24, 2001 @ 5:16am
Location: the Shades, Ankh-Morpock


Return to PocketFrog & PocketHAL


Sort


Forum Description

SDKs for fast and robust device-independent access to Pocket PC display hardware.

Moderators:

sponge, Kzinti

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum